Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4bd5abe9b344
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c723013d2969
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 6, 2014

  1. Implement Method#curry, which simply delegates to Proc#curry.

    Also fixes an existing bug in JRuby which would ignore the argument
    passed to Proc#curry() and would instead always use the Proc's arity.
    With that fixed, Proc#curry properly works with varargs now.
    
    The fixed regression was introduced in 7270345
    
    Conflicts:
    	core/src/main/java/org/jruby/RubyMethod.java
    cheald committed Nov 6, 2014
    Copy the full SHA
    f488a44 View commit details

Commits on Nov 7, 2014

  1. Merge pull request #2133 from cheald/method_curry

    Implement Method#curry, which simply delegates to Proc#curry.
    headius committed Nov 7, 2014
    Copy the full SHA
    c723013 View commit details
Showing with 8 additions and 3 deletions.
  1. +5 −0 core/src/main/java/org/jruby/RubyMethod.java
  2. +3 −3 core/src/main/ruby/jruby/kernel/proc.rb
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/RubyMethod.java
Original file line number Diff line number Diff line change
@@ -299,5 +299,10 @@ public int getLine() {
public IRubyObject parameters(ThreadContext context) {
return JRubyLibrary.MethodExtensions.methodArgs(this);
}

@JRubyMethod(optional = 1)
public IRubyObject curry(ThreadContext context, IRubyObject[] args) {
return to_proc(context, null).callMethod(context, "curry", args);
}
}

6 changes: 3 additions & 3 deletions core/src/main/ruby/jruby/kernel/proc.rb
Original file line number Diff line number Diff line change
@@ -2,21 +2,21 @@ class Proc
def curry(curried_arity = nil)
if lambda? && curried_arity
if arity > 0 && curried_arity != arity
raise ArgumentError, "Wrong number of arguments (%i for %i)" % [
raise ArgumentError, "wrong number of arguments (%i for %i)" % [
curried_arity,
arity
]
end

if arity < 0 && curried_arity < (-arity - 1)
raise ArgumentError, "Wrong number of arguments (%i for %i)" % [
raise ArgumentError, "wrong number of arguments (%i for %i)" % [
curried_arity,
-arity - 1
]
end
end

Proc.__make_curry_proc__(self, [], arity)
Proc.__make_curry_proc__(self, [], curried_arity || arity)
end

# Create a singleton class based on Proc that re-defines these methods but