Last active
February 23, 2016 00:15
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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