From: william robb Date: 2006-07-08T13:53:35+09:00 Subject: newbie Q - calling a method for an object in an .each block? Hello All. Sorry if this is obvious, but I have looked over the list (and pickax) and not been able to solve it. I am trying to iterate over a collection of objects, calling a method defined within each object. I have a class Card, with a method 'show' defined. I then create an array of these Card objects. For example: >hand = Array.new >ace = Card.new( some_parameters ) >hand[0] = ace >hand.push(Card.new( some_other_parameters)) etc. Now, >ace.show #works: =>"Card: A of Spades hand[0].show # works, calls the 'show' method, executed for the first 'card', the ace: =>"Card: A of Spades" But, >hand.each {|c| c.show} # dosn't produces the following, which looks to me like a dump of the array: =>[#, #] I fear I am misunderstanding something fundamental here, as I thought the block parameter c should get each element of the array in turn, and, each element being an object, I could call the methods associated with that object. Thanks for any insight, Will -- Posted via http://www.ruby-forum.com/.