Skip to content

Commit

Permalink
Support function arguments in Opal.$yieldX
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Oct 26, 2013
1 parent e390bc6 commit c5f3384
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions corelib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,20 @@

// handles yield for > 1 yielded arg
Opal.$yieldX = function(block, args) {
if (typeof(block) !== "function") {
throw Opal.LocalJumpError.$new("no block given");
}

if (block.length > 1 && args.length == 1) {
if (args[0]._isArray) {
return block.apply(null, args[0]);
}
}

if (!args._isArray) {
args = $slice.call(args);
}

return block.apply(null, args);
};

Expand Down

0 comments on commit c5f3384

Please sign in to comment.