From: Joshua Ballanco Date: 2011-04-25T23:59:50+09:00 Subject: [ruby-core:35881] [Ruby 1.9 - Bug #4610] Proc#curry behavior is inconsistent with lambdas containing default argument values Issue #4610 has been updated by Joshua Ballanco. Appologies for the formatting mistakes... If I curry a lambda with 3 arguments, then I can call three times with one argument each time to get the desired results: ruby-1.9.2-p180 :001 > l = ->(a, b, c) { puts "#{a}, #{b}, #{c}" } ruby-1.9.2-p180 :002 > c = l.curry ruby-1.9.2-p180 :003 > c.('one').('two').('three') one, two, three nil However, if the lambda has default values and I curry it, the entire lambda is evaluated after the first #call: ruby-1.9.2-p180 :004 > l = ->(a = 'ichi', b = 'ni', c = 'san') { puts "#{a}, #{b}, #{c}" } ruby-1.9.2-p180 :005 > c = l.curry ruby-1.9.2-p180 :006 > c.('one').('two').('three') one, ni, san NoMethodError: undefined method `call' for nil:NilClass This behavior seem very inconsistent. Ideally, if I wanted to use the default argument at a certain position in a currie proc, I would just #call with no arguments, like so: ruby-1.9.2-p180 :007 > c.('one').().('three') #=> Propose that this should result in: "one, ni, three" ---------------------------------------- Bug #4610: Proc#curry behavior is inconsistent with lambdas containing default argument values http://redmine.ruby-lang.org/issues/4610 Author: Joshua Ballanco Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: 1.9.2p180 If I curry a lambda with 3 arguments, then I can call three times with one argument each time to get the desired results: ruby-1.9.2-p180 :001 > l = ->(a, b, c) { puts "#{a}, #{b}, #{c}" } # ruby-1.9.2-p180 :002 > c = l.curry # ruby-1.9.2-p180 :003 > c.('one').('two').('three') one, two, three nil However, if the lambda has default values and I curry it, the entire lambda is evaluated after the first #call: ruby-1.9.2-p180 :004 > l = ->(a = 'ichi', b = 'ni', c = 'san') { puts "#{a}, #{b}, #{c}" } # ruby-1.9.2-p180 :005 > c = l.curry # ruby-1.9.2-p180 :006 > c.('one').('two').('three') one, ni, san NoMethodError: undefined method `call' for nil:NilClass This behavior seem very inconsistent. Ideally, if I wanted to use the default argument at a certain position in a currie proc, I would just #call with no arguments, like so: ruby-1.9.2-p180 :007 > c.('one').().('three') #=> Propose that this result in: "one, ni, three" -- http://redmine.ruby-lang.org