Arrays

obst = ["Apfel", "Birne", "Mango", "Weintraube"]
anbau = "Apfel", "Gurke", "Tomate"

p obst[1]
p obst[-2]
p obst[0..2]
p obst[1, 3]
puts "Anzahl Elemente in obst: #{obst.length}"
p "Differenz:", obst - anbau
p "Vereinigung:", obst + anbau
p "Durchschnitt:", obst & anbau

Ergebnis:
"Birne"
"Mango"
["Apfel", "Birne", "Mango"]
["Birne", "Mango", "Weintraube"]
Anzahl Elemente in obst: 4
"Differenz:"
["Birne", "Mango", "Weintraube"]
"Vereinigung:"
["Apfel", "Birne", "Mango", "Weintraube", "Apfel", "Gurke", "Tomate"]
"Durchschnitt:"
["Apfel"]

parallele_zuweisung.rb