Last Updated: February 25, 2016
·
1.049K
· hannesg

Use lambdas with case/when and ampex

A bit time has passed since my first protip concerning this topic. Now my pull-request for the ampex gem was merged with a cool syntax for lambdas with case/when.

After installing the gem you can now write code like this:

case something
when X.respond_to? :foo
  something.foo
when X.respond_to? :[]
  something['foo']
end