Afficher un message
Vieux 21/02/2008, 20h56   #3
Stéphane Wirtel
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to define the assignment operator in Ruby ?

> Stephanie,
Stephane and not Stephanie :-) Stephanie is the firstname for a girl
>
> In ruby, we don't assign to an instance as you mentioned, we assign to a
> variable that can hold any type. We therefore can't override the
> assignment operator.
>
> BUT you can override an assignment operation.. such as
>
> class Foo
> def bar= (val)
> @bar = val
> p "I am assigning #{val} to @bar"
> end

Grrr, so I have reason about this operator, I can't override it.

Thanks
  Réponse avec citation
 
Page generated in 0,06730 seconds with 9 queries