It's GG

Life is simple...

1 note

New proc syntax in 1.9

BEGIN {
  puts "Ruby Version : #{RUBY_VERSION}"
}

succ = ->(x=0) { x + 1 }
p succ.call
p succ.call(2)

successor = Proc.new {|x=0| x + 1}
p successor.call
p successor.call(10)

Output

Ruby Version : 1.9.1
1
3
1
11

But thanks, I will stick with the old syntax!

Filed under ruby snippet

  1. itsgg posted this