Vidar Hokstad wrote:
> Julien Gaugaz wrote:
>   
>> Ah, ok, thanks a lot. I understood why i could use '***' as an infix
>> operator. But still, there shouldn't be any difference between a call
>> like m.*** n  and m.triple_star n... But it seems there is since
>> m.triple_star works and m.*** don't.
>>
>> I don't get it.
>>     
>
> Again, the only reason you can use a name like '**' is that it's one of
> the predefined operators. You can't just use any characters you want in
> a method name - the only method names you can use "special" characters
> like '*' in are method names matching the specific operators you can
> override.
>
> I think your confusion probably stems from the fact that this parses
> without errors:
>
>   def *** other
>   end
>
> Hower, try to run this:
>
>   class Foo
>       def *** other
>       end
>   end
>
>   p Foo.new.methods.sort
>
> This should print out a sorted list of methods of instances of Foo.
> You'll see "**" shows up as the first method. The reason is that "def
> *** other" gets parsed as "def **  *other" (note the space). "*" in
> this case is the "splat" operator, that indicates that "other" will
> hold an arbitrary number of arguments in an array.
>
> So you haven't defined Foo#***, but Foo#**.
>   
Nice explanation! I was indeed misled by the fact that some operators 
are actually implemented as methods. And therefore considered the 
character '*' as a standard one for a method...

As you might have guessed I'm a complete newbie to Ruby ;-)

Thank you again for those enlightenments!

Cheers,

Julien
> Vidar
>
>
> Vidar
>
>
>
>