Project

General

Profile

Actions

Feature #4288

closed

Allow invoking arbitrary method names with foo."something" syntax

Added by headius (Charles Nutter) almost 14 years ago. Updated about 7 years ago.

Status:
Closed
Target version:
[ruby-core:34550]

Description

=begin
This is one Groovy feature I tend to like.

For non-standard or arbitrary method names, it would be nice to have a way to invoke them directly that doesn't require the parser to be made more complex nor require an intermediate "send" call. Groovy does this by allowing the following form:

foo."asdf"()

This syntax would make it easier to integrate with other languages that have different naming rules. For example, =!@+= is a valid operator in Scala. With this syntax, you could invoke it as

foo."=!@+=" bar

The alternative in JRuby is that we have to map such names as eq_bang_at_plus_eq, which is certainly not as elegant, or force people to use send (and force them to use :"" anyway, since :=!@+= is not a valid symbol).

It's left up for debate whether string interpolation should be allowed in this syntax.
=end


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #5394: Anonymous Symbols, Anonymous MethodsRejected10/04/2011Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0