Stefano Crocco
1/26/2007 12:11:00 AM
Alle 01:02, venerdì 26 gennaio 2007, Neville Franks ha scritto:
> Hi, I've been working on adding Ruby language support to our IDE "ED for
> Windows" the past few weeks and am stuck understanding the marked
> statement in this code:
>
> module Mod
> def size
> @size
> end
> def size=(val) # what does this mean
> @size = val
> end
> end
>
> None of the reference material I've found so far shows this. I saw it in
> the documentation for: attr(symbol, writable=false) => nil
>
> Thanks,
> Neville
def size=(val) is simply the definition of a method called size=, which
accepts the parameter val. It's the ruby way of allowing write access to an
instance variable. Its role is similar to C++ setter functions. When you
write
an_object.var=2
I hope this answers your question.
Stefano