Advanced Ruby Arrays

Revision as of 20:29, 26 November 2007 by Neil (Talk | contribs) (New page: In the Understanding Ruby Arrays we looked at the basics of arrays in Ruby. In this chapter we will look at arrays in more detail. == Combining Ruby Arrays == Arrays in Ruby can be c...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Revision as of 20:29, 26 November 2007 by Neil (Talk | contribs) (New page: In the Understanding Ruby Arrays we looked at the basics of arrays in Ruby. In this chapter we will look at arrays in more detail. == Combining Ruby Arrays == Arrays in Ruby can be c...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In the Understanding Ruby Arrays we looked at the basics of arrays in Ruby. In this chapter we will look at arrays in more detail.

Combining Ruby Arrays

Arrays in Ruby can be concatenated using a number of different approaches. One option is to simply add' them together:

days1 = ["Mon", "Tue", "Wed"]
days2 = ["Thu", "Fri", "Sat", "Sun"]
days = days1 + days2
=> ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

Arrays can also be combined using the << operator: