Ruby 2.1 returns a symbol when defining a method

Posted . Visible to the public.

Since Ruby 2.1, defining a method returns its name as a Symbol:

def foo() end             # => :foo
define_method :foo do end # => :foo

You can use this to do Python-like decorators like so:

private def foo; end 
memoize def foo; end 
Dominik Schöler
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2014-06-17 17:14)