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
Written by Hannes Georg
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#