Ruby - Array addition and Concatenation

Introduction

If you have two arrays, you can quickly combine their results into one:

Demo

x = [1, 2, 3] 
y = ["a", "b", "c"] 
z = x + y # from   w w  w .ja v  a2 s. c o  m
p z

Result

We're using p here instead of puts z.inspect.

Related Topics