V
Ves Pasian
The following code works fine (windows XP, Ruby 1.86)
Card = Struct.newrank, :suit)
class Card
def to_s
"#{rank} of #{suit}"
end
end
c = Card.new(2, "hearts")
c.rank
#####################################################
The following doesn't work:
Card = Struct.newrank, :suit)
class Card
attr_reader :rank, :suit
def to_s
"#{rank} of #{suit}"
end
end
c = Card.new(2, "hearts")
c.rank
####################################
Any ideas why?
TIA,
ves
Card = Struct.newrank, :suit)
class Card
def to_s
"#{rank} of #{suit}"
end
end
c = Card.new(2, "hearts")
c.rank
#####################################################
The following doesn't work:
Card = Struct.newrank, :suit)
class Card
attr_reader :rank, :suit
def to_s
"#{rank} of #{suit}"
end
end
c = Card.new(2, "hearts")
c.rank
####################################
Any ideas why?
TIA,
ves