Forum: Ruby How is alias magic?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F1938de600a3feacd015051492fdaf0f?d=identicon&s=25 LAMBEAU Bernard (Guest)
on 2009-03-21 18:12
(Received via mailing list)
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
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 Joel VanderWerf (Guest)
on 2009-03-21 18:17
(Received via mailing list)
LAMBEAU Bernard wrote:
> thx
> blambeau

Nope, alias is a keyword, not a method, so it has special syntax.
68a08995ddf9b3f8a0b562ed0baf63af?d=identicon&s=25 Michael Bruschkewitz (Guest)
on 2009-06-05 09:50
(Received via mailing list)
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...
This topic is locked and can not be replied to.