Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Subject: What *exactly* does an instance variable in the
Arno J.
8/16/2007 3:43:00 PM
Any instance variable refers to the object currently being self at the
moment.
> @tl_instance = "hello ruby"
self here is "main", which is the top level default object
> puts @tl_instance
>
> def tl_method
> puts "from tl_method -- @tl_instance: #{@tl_instance}"
> end
self here is "main" too
>
> tl_method
>
=> Working as expected
> class Tl_class
> def tlc_method
> puts "from tlc_method -- @tl_instance: #{@tl_instance}"
> end
> end
>
> Tl_class.new.tlc_method
> ------------
Inside tlc.method, self is the "Tl_class.new" object, which doesn't know
about any @tl_instance.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Subject: What *exactly* does an instance variable in the
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password