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 UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
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)