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: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e258f76920bf
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 49ab70f731eb
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Nov 5, 2013

  1. Cleanup Kernel#proc

    meh committed Nov 5, 2013

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    31c12c5 View commit details
  2. Copy the full SHA
    49ab70f View commit details
Showing with 16 additions and 15 deletions.
  1. +16 −15 corelib/kernel.rb
31 changes: 16 additions & 15 deletions corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -404,13 +404,12 @@ def private_methods
end

def proc(&block)
%x{
if (block === nil) {
#{ raise ArgumentError, 'no block given' };
}
block.is_lambda = false;
return block;
}
unless block
raise ArgumentError, "tried to create Proc object without a block"
end

`block.is_lambda = false`
block
end

def puts(*strs)
@@ -450,15 +449,17 @@ def raise(exception = undefined, string = undefined)

def rand(max = undefined)
%x{
if(!max) {
if (max === undefined) {
return Math.random();
} else {
if (max._isRange) {
var arr = max.$to_a();
return arr[#{rand(`arr.length`)}];
} else {
return Math.floor(Math.random() * Math.abs(parseInt(max)));
}
}
else if (max._isRange) {
var arr = #{max.to_a};
return arr[#{rand(`arr.length`)}];
}
else {
return Math.floor(Math.random() *
Math.abs(#{Opal.coerce_to max, Integer, :to_int}));
}
}
end