Collections
Array Methods
Ruby arrays grow with methods such as <<, and they can report their size or join their values.
Array Methods
array_methods.rb
items = ["pencil", "notebook"]
new_item =
items << new_item
puts "count=#{items.length}"
puts "items=#{items.join(", ")}"
items = ["pencil", "notebook"]
new_item =
items << new_item
puts "count=#{items.length}"
puts "items=#{items.join(", ")}"
items = ["pencil", "notebook"]
new_item =
items << new_item
puts "count=#{items.length}"
puts "items=#{items.join(", ")}"
array method
Array methods change or summarize the values stored in order.