Skip to content

Instantly share code, notes, and snippets.

@phluid61
Last active August 24, 2016 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phluid61/e8764994e0dea24f6b1a to your computer and use it in GitHub Desktop.
Save phluid61/e8764994e0dea24f6b1a to your computer and use it in GitHub Desktop.
JRuby proc currying error
puts RUBY_DESCRIPTION
if $VERBOSE
# Works:
prc = proc{|a,b,c| [a,b,c] }
p prc.curry.call()
p prc.curry.call(1)
p prc.curry.call(1,2)
p prc.curry.call(1,2,3)
end
# Doesn't work:
prc = proc{|a,b,*c| [a,b,*c] }
p prc.curry.call()
p prc.curry.call(1)
p prc.curry.call(1,2)
p prc.curry.call(1,2,3)
$ jruby proc_curry.rb
jruby 1.7.17 (1.9.3p392) 2014-12-09 fafd1a7 on OpenJDK 64-Bit Server VM 1.7.0_65-b32 +jit [linux-amd64]
[nil, nil]
[1, nil]
[1, 2]
[1, 2, 3]
$ ruby proc_curry.rb
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
#<Proc:0x00000000b89930>
#<Proc:0x00000000b89728>
[1, 2]
[1, 2, 3]
@phluid61
Copy link
Author

Note: it doesn't matter if I use Proc#call or #[]

@phluid61
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment