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   ww  w .j  av a 2  s  . c  om
p z

Result

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

Related Topics