Feature #8807
Custom literals
Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
Description
So why can't we define custom literals? There's been recent discussion about adding a new freeze literal. Would have been nice if coders could have defined it for themselves, then it would have been more clear if there really was enough use to add it to core.
I imagine the syntax of such a feature to be quite simple.
def %foo(string, mod=nil)
p [string, mod]
end
%foo{something}o
=> ["something", "o"]
Updated by drbrain (Eric Hodel) over 7 years ago
If you define a new literal in file "a.rb" you cannot use it in that file that defined it as it has already been parsed. This may be confusing.
Updated by naruse (Yui NARUSE) over 7 years ago
- Target version changed from 2.1.0 to 3.0