Read more

Ruby 2.1 returns a symbol when defining a method

Dominik Schöler
June 17, 2014Software engineer at makandra GmbH

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

def foo() end             # => :foo
define_method :foo do end # => :foo
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

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

private def foo; end 
memoize def foo; end 
Posted by Dominik Schöler to makandra dev (2014-06-17 19:14)