Ruby/Array/Array Addition
Материал из Wiki.crossplatform.ru
Array Addition and Concatenation
x = [1, 2, 3] y = ["a", "b", "c"] z = x + y puts z.inspect
concatenate is with the
yrs = [1999] yrs << 2000 # => [1999, 2000] # You can chain these, too: yrs << 2001 << 2002 << 2003 # => [1999, 2000, 2001, 2002, 2003]
Concatenation with the + operator
q1 = %w[ January February March ] q2 = %w[ April May June ] q3 = %w[ July August September ] q4 = %w[ October November December ] half1 = q1 + q2 half2 = q3 + q4 yr = half1 + half2