Feature #8807

Custom literals

Added by Thomas Sawyer 8 months ago. Updated 7 months ago.

[ruby-core:56767]
Status:Open
Priority:Normal
Assignee:-
Category:core
Target version:Next Major

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"]

History

#1 Updated by Eric Hodel 8 months 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.

#2 Updated by Boris Stitnicky 8 months ago

-1

#3 Updated by Yui NARUSE 7 months ago

  • Target version changed from 2.1.0 to Next Major

Also available in: Atom PDF