# Ruby question

**URL:** <https://www.ruby-forum.com/t/ruby-question/90181>\
**Category:** Rails\
**Created:** [March 26, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/ruby-question/90181 "2007-03-26T18:01:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@jim](https://www.ruby-forum.com/u/jim)\
**Post date:** [March 26, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/ruby-question/90181/1 "2007-03-26T18:01:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ac91a4/32.png) [@jim](https://www.ruby-forum.com/u/jim)\
**Post date:** [March 26, 2007, 6:20pm UTC](https://www.ruby-forum.com/t/ruby-question/90181/2 "2007-03-26T18:20:46Z")

</div>

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
