How is alias magic?

L

LAMBEAU Bernard

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
 
J

Joel VanderWerf

LAMBEAU said:
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.
 
M

Michael Bruschkewitz

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:

....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top