unknown wrote:
> Hi --
> 
> On Fri, 26 Jan 2007, Neville Franks wrote:
> 
>> Back to my original code snippet. Isn't @size = val redundant?
> 
> Not if you want @size set to val :-)
> 
> Consider this:
> 
>    class C
>      def size=(val)
>        puts "Nice try!"
>      end
>    end
> 
>    c = C.new
>    c.size = 20    # Nice try!
> 
> The instance variable @size is nowhere to be seen, and has not been
> involved with any of this.  size= is just a method name.
> 
> 

Ok I finally completely understand. :)
a) size= is the method name.
b) (val) is the method parameter
c) @size=val assigns val to @size.

You'll need to excuse this poor old C++ guy being a bit slow at times.
> David


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