Skip to content

Instantly share code, notes, and snippets.

@theHamdiz
Last active February 23, 2016 00:15
Show Gist options
  • Select an option

  • Save theHamdiz/fe9825df5e9aa3ced219 to your computer and use it in GitHub Desktop.

Select an option

Save theHamdiz/fe9825df5e9aa3ced219 to your computer and use it in GitHub Desktop.
The lambda literal symbol, which was introduced recently and is the new default way to define scopes in rails
# The lambda literal symbol ->
# with it you can store a whole
# anonymous method in a variable
# and access it later
# Introduced recently
# The new default way to define scopes in rails
one_plus_one = -> { 1 + 1 }
p one_plus_one.call
###############################################
expon = -> (v) { v ** v }
p expon.call(4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment