Friday, March 03, 2006

Travering Arrays, Hashes and Collections. [Ruby on Rails]

Traversing a hash's values


myitems.each_value do |item|
# do stuff with item
end



Traversing an array (similarly a collection can be traversed)


myitems.each do |key, value|
# do stuff with key and value
end

0 Comments:

Post a Comment

<< Home

eXTReMe Tracker