Ruby question

Pardon my noobiness, but I’m learning both Ruby and Ror at the same
time and am trying to understand Ruby a bit here.

Say I have:

class Ticket
attr_accessor :venue, :date

def Test
@venue = “Some Venue”
@date = “03/31/2007”
end

end

x=Ticket.new
x.venue=“aaa”
puts x.venue

x.Test
puts x.venue

which outputs:

aaa
Some Venue


My question is:
Is the venue variable I’m referring to above, the same variable or are
they different? Is my call to x.Test (which in turn sets @venue)
essentially overwriting the same :venue instance variable? I’m just
trying to understand this a little better.

Thanks.

Irb tells all. They are the same object. Your call test over writes the
@venue for instance x and returns the @date value.

irb(main):009:0> x=Ticket.new
=> #Ticket:0xb7c8aab0
irb(main):010:0> x.venue=“aa”
=> “aa”
irb(main):011:0> puts x.venue
aa
=> nil
irb(main):012:0> x.Test
=> “03/31/2007”
irb(main):013:0> puts x.venue
Some Venus
=> nil
irb(main):014:0> x
=> #<Ticket:0xb7c8aab0 @venue=“Some Venus”, @date=“03/31/2007”>

Stephen B. IV