Underscore: _.random์€ ๋•Œ๋•Œ๋กœ ๋‘ ๋ฐฐ๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2017๋…„ 08์›” 20์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: jashkenas/underscore

_.random = function(min, max) {
    if (max == null) {
        max = min;
        min = 0;
    }
        // if min is not integer, we can not get integer as return
    return min + Math.floor(Math.random() * (max - min + 1));
}

_.random(5.1, 6) ๊ทธ๋Ÿฌ๋ฉด ์ •์ˆ˜ ๋ฐ˜ํ™˜์ด ์•„๋‹Œ double์ด ๋ฐ˜ํ™˜๋ฉ๋‹ˆ๋‹ค. ์˜์‚ฌ๊ฐ€ ์ž„์˜์˜ ์ •์ˆ˜๋ฅผ ๋ฐ˜ํ™˜์œผ๋กœ ์–ป์„ ์ˆ˜ ์žˆ๋‹ค๊ณ  ๋งํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ฒ„๊ทธ๋ผ๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด์— ๋Œ€ํ•œ pull ์š”์ฒญ์„ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. #2696์„ ์ฐธ์กฐํ•˜์„ธ์š”

๋ชจ๋“  3 ๋Œ“๊ธ€

์ตœ์†Œ๊ฐ’๊ณผ ์ตœ๋Œ€๊ฐ’์€ ๊ณต์‹์„ ์ ์šฉํ•˜๊ธฐ ์ „์— ๋ฐ˜์˜ฌ๋ฆผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ด์— ๋Œ€ํ•œ pull ์š”์ฒญ์„ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. #2696์„ ์ฐธ์กฐํ•˜์„ธ์š”

์ด ๋ฌธ์ œ๋Š” ๋‹ซ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. https://github.com/jashkenas/underscore/pull/2696#issuecomment -343276407 ์ฐธ์กฐ

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰