Posted over 5 years ago. Visible to the public.

Ruby 2.1 returns a symbol when defining a method

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

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Dominik Schöler
Last edit:
over 5 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more