Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible in Ruby to define a method which name ends with : (colon)?

Just wondering if it is possible, by some loophole, to define a method name that ends in a colon. The purpose it to make things look like this:

mymethod: arg1,arg2,arg3
like image 264
themirror Avatar asked May 27 '10 18:05

themirror


1 Answers

It is technically possible to define a method with that name, but you can't call it like that because of syntax rules. (The colon is considered a different token.) You would have to do send('mymethod:', args), which defeats the purpose.

like image 95
mckeed Avatar answered Sep 24 '22 20:09

mckeed