From: Vladimir Van Bauenhoffer Date: 2011-09-16T05:46:53+09:00 Subject: Re: Some newbie questions alberto kaputchella wrote in post #1022215: > Vladimir Van Bauenhoffer wrote in post #1022210: >> I got some newbie questions which I would very much appreciate if >> someone could answer (in a way that a newbie would understand): >> >> 1. What does @ mean in Ruby? Im sure I have seen variables like this: >> @variable. A new datatype like the :symbol perhaps? >> > > The @ means that the variable is an object variable, its scope is > within, and is associated to, the current object. > > For example, > > class Person > def initialize(name) > @name=name > end > > def say_your_name > puts @name > end > > In this class, you assign the name provided to the class to @name. > @name as an object variable, is then accessible from any other method > inside the object. Thanks for answering that question. In Python (the only other language I know a little of) you dont have to do anything special with the name when you make an object. I wonder why it's like that in Ruby. -- Posted via http://www.ruby-forum.com/.