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: 8cfd88d83d34
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0314ff118d6a
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 4, 2016

  1. Copy the full SHA
    2aadefb View commit details
  2. Copy the full SHA
    0314ff1 View commit details
Showing with 13 additions and 6 deletions.
  1. +10 −4 core/src/main/java/org/jruby/RubyEnumerator.java
  2. +3 −2 spec/java_integration/extensions/iterable_spec.rb
14 changes: 10 additions & 4 deletions core/src/main/java/org/jruby/RubyEnumerator.java
Original file line number Diff line number Diff line change
@@ -477,20 +477,26 @@ public IRubyObject each_with_index(ThreadContext context, final Block block) {
return with_index_common(context, block, "each_with_index", context.nil);
}

@JRubyMethod(name = "with_index")
public IRubyObject with_index(ThreadContext context, final Block block) {
return with_index19(context, block);
return with_index_common(context, block, "with_index", context.nil);
}

@JRubyMethod(name = "with_index")
@Deprecated
public IRubyObject with_index19(ThreadContext context, final Block block) {
return with_index_common(context, block, "with_index", context.nil);
return with_index(context, block);
}

@JRubyMethod(name = "with_index")
public IRubyObject with_index19(ThreadContext context, IRubyObject arg, final Block block) {
public IRubyObject with_index(ThreadContext context, IRubyObject arg, final Block block) {
return with_index_common(context, block, "with_index", arg);
}

@Deprecated
public IRubyObject with_index19(ThreadContext context, IRubyObject arg, final Block block) {
return with_index(context, arg, block);
}

private volatile Nexter nexter = null;

@JRubyMethod
5 changes: 3 additions & 2 deletions spec/java_integration/extensions/iterable_spec.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
ret = path.each { |p| paths << p.to_s }
expect( paths ).to_not be_empty
expect( paths.last ).to eq 'iterable_spec.rb'
expect( ret ).to eq path
expect( ret ).to be path
end

it 'iterates with an Enumerator on #each' do
@@ -29,14 +29,15 @@
expect( paths ).to_not be_empty
expect( paths[-1][0].to_s ).to eq 'iterable_spec.rb'
expect( paths[-1][1] ).to eq paths.size - 1
expect( ret ).to eq path
expect( ret ).to eql path

paths = []; idxs = []
ret = path.each_with_index { |p, i| paths << p; idxs << i }
expect( paths ).to_not be_empty
expect( paths[-1].to_s ).to eq 'iterable_spec.rb'
expect( idxs[0] ).to eq 0
expect( idxs[-1] ).to eq paths.size - 1
expect( ret ).to be path
end

it 'iterates with an Enumerator on #each_with_index' do