From: Li Chen on
Josh Cheek wrote:
> On Sun, Apr 11, 2010 at 2:15 PM, Li Chen <chen_li3(a)yahoo.com> wrote:
>
>> Hi Andrea,
> Except on assignments, because it looks like you are creating a local
> variable.
> Example:
>
> class Foo
> attr_accessor :bar
> def bad_assign
> bar = 'baz'
> defined? bar
> end
> def good_assign
> self.bar = 'baz'
> defined? bar
> end
> end
>
> foo = Foo.new
>
> foo.bad_assign # => "local-variable"
> foo.bar # => nil
>
> foo.good_assign # => "method"
> foo.bar # => "baz"


Thank you so much. Where can I find more info about this usage?

Li

--
Posted via http://www.ruby-forum.com/.