From: William Song Date: 2010-06-08T08:16:57+09:00 Subject: Re: Defining struct in a class Rein Henrichs wrote: > On 2010-06-07 15:16:33 -0700, William Song said: > >> >> This will give me an error message saying the push is not defined for >> NilClass. How should I fix this? > > The error you reported has nothing to do with your Card struct. Besides > which, your code works for me as is. Sorry, I meant to put it into a function. I over-simplified it when posted here. class Cards Card = Struct.new(:suit, :number) @cardsOnHand=[] def a() @cardsOnHand.push(Card.new("S","5")) end end cards = Cards.new cards.a() The above code will give an error. -- Posted via http://www.ruby-forum.com/.