Created
April 3, 2018 10:57
-
-
Save mykiy/6059e691d98d6c2d7178ea0519edfe4d to your computer and use it in GitHub Desktop.
procs in ruby
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
| p = Proc.new do #proc is a object, actually a block of code stored in a instance variable | |
| "hello" | |
| end | |
| p.call | |
| ----- | |
| p = Proc.new do |num| | |
| num * num | |
| end | |
| p.call(5) | |
| =>25 | |
| ---- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment