From: Ves Pasian Date: 2008-12-04T08:28:03+09:00 Subject: Struct class The following code works fine (windows XP, Ruby 1.86) Card = Struct.new(:rank, :suit) class Card def to_s "#{rank} of #{suit}" end end c = Card.new(2, "hearts") c.rank >> 2 ##################################################### The following doesn't work: Card = Struct.new(:rank, :suit) class Card attr_reader :rank, :suit def to_s "#{rank} of #{suit}" end end c = Card.new(2, "hearts") c.rank >> nil #################################### Any ideas why? TIA, ves -- Posted via http://www.ruby-forum.com/.