From: Johannes Friestad Date: 2005-12-07T14:29:12+09:00 Subject: Re: Mixins and variables OK, thanks. Can I force "x=(whatever)" to mean a method call instead of an assignment? I thought the parantheses were supposed to do that? jf On 12/6/05, Daniel Sheppard wrote: > It's got nothing to do with mixins: > > class TestClass > def x=(arg) > @x = arg > end > def x > @x > end > def monkey(arg) > x = arg > end > end > > irb(main):012:0> a = TestClass.new > => # > irb(main):013:0> a.monkey('aa') > => "aa" > irb(main):014:0> a.x > => nil > > In the monkey method, x = arg is assigning to the local variable x, not > calling the method x=(). > > Refer to the x variable either as self.x or @x. >