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:
=>[#<Card:0x2647f8 @face="Up", @value=12, @suit="s">, #<Card:0x20e3e4 
@face="Up", @value=0, @suit="d">]

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/.