2009/8/25 Sarah Allen <sarah / ultrasaurus.com>:
> 7stud -- wrote:
>> Ruby gives you a choice with some methods, like +() and =3D(), to use a
>> special syntax. =A0Special syntaxes are commonly known as "syntactic
>> sugar". =A0 What happens is that the "sugared syntax" is converted into
>> the normal method call, so:
>>
>> 1 + 2 =A0becomes 1.+(2)
>>
>> and
>>
>> obj.x =3D 10 becomes obj.x=3D(10) =A0(where the method name is 'x=3D')
>
> So, where might I find a list of the special sugary methods?

There is a list in the printed edition of the Pickaxe IIRC.

> and may I
> define my own? =A0I know I can override + and =3D, but could I make =DF o=
r foo
> be sent to an object with syntax such as 4 foo 4 or "test"=DF"this" ? =A0=
(I
> don't know that I would want to, but I am curious)

You cannot as that would mean changing of the language's syntax.

Kind regards

robert


--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/