This experimental operator was added in Ruby
v2.7.0preview1 but this feature has
now been reverted.
This won’t be a part of the Ruby
This feature was inspired by functional programming.
But according to Matz, instead of this being part of a central design, it was more of an ad hoc addition.
He also stated he doesn’t like the Tetris operator
.:, which looks like Braille.
Some other community members pointed out that feature requests like this may hinder a systematic expansion of functional programming in Ruby, or at the very least become a useless feature.
The discussion regarding this reversion can be found here along with Matz’s comments.
The examples provided in this post could be tested with Ruby
Ruby 2.7 adds experimental shorthand operator for
This allows method object access using
This feature was first proposed 3 years ago and an experimental version of the feature is finally out for use on Ruby 2.7
You can follow more discussion and alternatives to this syntax here.
We can access methods on an Object using the
method call on an Object.
We can use this method object returned from
to be passed around,
which can then be called elsewhere.
In the example above we are passing method object,
to the map method.
We are passing a reference to the method here to be called,
instead of actually invoking it,
This is a common pattern, for example:
Method shorthand operator
As you can see, calling
Object.method(:method_name) can be too verbose.
Ruby 2.7 introduces an experimental feature to access methods in a shorthand way.
Where it can be accessed
The method call is available on
Object it is made available on Object instances, Classes, Modules, etc.