Skip to content

Commit

Permalink
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1334,10 +1334,6 @@ public Object inject(VirtualFrame frame, RubyArray array, Object initial, RubyPr

final Object[] store = array.slowToArray();

if (store.length < 2) {
throw new UnsupportedOperationException();
}

Object accumulator = initial;

for (int n = 0; n < array.getSize(); n++) {
@@ -1354,7 +1350,11 @@ public Object inject(VirtualFrame frame, RubyArray array, RubySymbol symbol, Und
final Object[] store = array.slowToArray();

if (store.length < 2) {
throw new UnsupportedOperationException();
if (store.length == 1) {
return store[0];
} else {
return getContext().getCoreLibrary().getNilObject();
}
}

Object accumulator = dispatch.call(frame, store[0], symbol, null, store[1]);

0 comments on commit 28030d0

Please sign in to comment.