Last active
August 24, 2016 05:02
-
-
Save phluid61/e8764994e0dea24f6b1a to your computer and use it in GitHub Desktop.
JRuby proc currying error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: it doesn't matter if I use Proc#call or #[]