Skip to content

Instantly share code, notes, and snippets.

@lukaszsagol
Created September 24, 2013 11:55
Show Gist options
  • Save lukaszsagol/6683649 to your computer and use it in GitHub Desktop.
Save lukaszsagol/6683649 to your computer and use it in GitHub Desktop.
Lambdas in case expressions
def is(method_sym)
->(subject) { subject.send method_sym }
end
case user
when is(:admin) then puts 'Woohoo! Admin'
when is(:editor) then puts 'Editor'
else puts 'User'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment