- Block: Anonymous piece of code passed to methods.
3.times { puts "Hello" }
- Proc: Saved block that can be reused.
say = Proc.new { puts "Hi" }
say.call
- Lambda: Like a Proc but stricter about arguments.
l = ->(x) { x*x }
puts l.call(5) # 25
Leave a Reply