Created
June 5, 2014 05:13
-
-
Save st98/ee2eb080ff9b3a38c3d0 to your computer and use it in GitHub Desktop.
Number#step (Ruby の Numeric#step の劣化版)。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.step = function (limit, step, callback) { | |
var n = Number(this); | |
if (typeof step === 'function') { | |
callback = step; | |
step = 1; | |
} | |
while (n <= limit) { | |
callback(n); | |
n += step; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment