Skip to content

Commit eb13bde

Browse files
authored
Merge pull request #7373 from headius/hash_each_lambda
Always yield two-elt ary from Hash#each to lambda
2 parents 500589e + 0c00542 commit eb13bde

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/main/java/org/jruby/RubyHash.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,9 @@ public RubyHash each_pairCommon(final ThreadContext context, final Block block)
15641564
private static final VisitorWithState<Block> YieldKeyValueArrayVisitor = new VisitorWithState<Block>() {
15651565
@Override
15661566
public void visit(ThreadContext context, RubyHash self, IRubyObject key, IRubyObject value, int index, Block block) {
1567-
if (block.getSignature().arityValue() > 1) {
1567+
if (block.type == Block.Type.LAMBDA) {
1568+
block.call(context, context.runtime.newArray(key, value));
1569+
} else if (block.getSignature().arityValue() > 1) {
15681570
block.yieldSpecific(context, key, value);
15691571
} else {
15701572
block.yield(context, context.runtime.newArray(key, value));

0 commit comments

Comments
 (0)