Hello,
I’ve been looking at the array stuff in the Noobkit, but I can’t seem
to find how to insert another entry in the array… Pretty much, I’m
going to be iterating through stuff and catching some things and adding
them to an array. I want to always add to the end of the array… In
stuff I’ve seen, you must define an index.
Any suggestions?
Thanks,
@a = Array.new
@a.push “item1”
@a << “item2”
@a.join(",") => “item1”, “item2”
that’s not correct. This is what it does:
a = Array.new
=> []
a.push “item1”
=> [“item1”]
a << “item2”
=> [“item1”, “item2”]
a.join(“,”)
=> “item1,item2”
Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #4 coming soon!
http://sensei.zenunit.com/
On 15/04/2008, at 12:02 PM, Nathan E. wrote:
@a = Array.new
@a.push “item1”
@a << “item2”
@a.join(“,”) => “item1”, “item2”
Posted via http://www.ruby-forum.com/.
/