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 Becker IV
On 3/26/07, jim <jjones3535a-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:>
>
> 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.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---