[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How is alias magic?

LAMBEAU Bernard

3/21/2009 5:09:00 PM

Hi all,

Is there any way to create a alias-like method allowing arguments not
to be separated by comma?

def my_alias(from, to)
...
end
myalias :me :you

thx
blambeau

2 Answers

Joel VanderWerf

3/21/2009 5:14:00 PM

0

LAMBEAU Bernard wrote:
> Hi all,
>
> Is there any way to create a alias-like method allowing arguments not
> to be separated by comma?
>
> def my_alias(from, to)
> ...
> end
> myalias :me :you
>
> thx
> blambeau

Nope, alias is a keyword, not a method, so it has special syntax.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407

Michael Bruschkewitz

6/5/2009 7:48:00 AM

0

As we discuss already some weird issues on this list:
Wouldn't it be possible to add some more "syntactic sugar" to Ruby?

What about a "operator" which uses rest of current line as string argument?

Example:

def interprete s
p s.split
end
interprete: 1 2 3

should show ["1", "2", "3"]...

Or, possibly, put ':' at the end of param-list:
def interprete s:

....


"Joel VanderWerf" <vjoel@path.berkeley.edu> schrieb im Newsbeitrag
news:49C520ED.8000508@path.berkeley.edu...
> LAMBEAU Bernard wrote:
>> Hi all,
>>
>> Is there any way to create a alias-like method allowing arguments not
>> to be separated by comma?
>>
>> def my_alias(from, to)
>> ...
>> end
>> myalias :me :you
>>
>> thx
>> blambeau
>
> Nope, alias is a keyword, not a method, so it has special syntax.
>
> --
> vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407
>