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: 730c677e784c
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: acb82d711a5f
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 7, 2015

  1. Copy the full SHA
    21e03b3 View commit details

Commits on Feb 10, 2015

  1. Merge pull request #2576 from Who828/fix_2553

    Fix the bug with size with each_slice without block
    enebo committed Feb 10, 2015
    Copy the full SHA
    acb82d7 View commit details
Showing with 6 additions and 1 deletion.
  1. +1 −1 core/src/main/java/org/jruby/RubyArray.java
  2. +5 −0 core/src/main/java/org/jruby/RubyEnumerator.java
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyArray.java
Original file line number Diff line number Diff line change
@@ -1608,7 +1608,7 @@ public IRubyObject each_slice(ThreadContext context, IRubyObject arg, Block bloc
final int size = RubyNumeric.num2int(arg);
final Ruby runtime = context.runtime;
if (size <= 0) throw runtime.newArgumentError("invalid slice size");
return block.isGiven() ? eachSlice(context, size, block) : enumeratorize(context.runtime, this, "each_slice", arg);
return block.isGiven() ? eachSlice(context, size, block) : enumeratorizeWithSize(context, this, "each_slice", arg, arg);
}

/** rb_ary_each_index
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/RubyEnumerator.java
Original file line number Diff line number Diff line change
@@ -124,6 +124,11 @@ public static IRubyObject enumeratorizeWithSize(ThreadContext context, IRubyObje
return enumeratorizeWithSize(context, object, method, NULL_ARRAY, sizeFn);
}

public static IRubyObject enumeratorizeWithSize(ThreadContext context, IRubyObject object, String method,IRubyObject arg, IRubyObject size) {
Ruby runtime = context.runtime;
return new RubyEnumerator(runtime, runtime.getEnumerator(), object, runtime.fastNewSymbol(method), new IRubyObject[] { arg }, size);
}

public static IRubyObject enumeratorize(Ruby runtime, IRubyObject object, String method) {
return new RubyEnumerator(runtime, runtime.getEnumerator(), object, runtime.fastNewSymbol(method), IRubyObject.NULL_ARRAY);
}