Skip to content

Instantly share code, notes, and snippets.

@mykiy
Created April 3, 2018 10:57
Show Gist options
  • Select an option

  • Save mykiy/6059e691d98d6c2d7178ea0519edfe4d to your computer and use it in GitHub Desktop.

Select an option

Save mykiy/6059e691d98d6c2d7178ea0519edfe4d to your computer and use it in GitHub Desktop.
procs in ruby
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