This file contains hidden or 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
| var a = true | |
| typeof a | |
| => "boolean" | |
| a.constructor.name | |
| => "Boolean" | |
| typeof Boolean | |
| => "function" | |
| Boolean.constructor.name | |
| => "Function" |
This file contains hidden or 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
| var a1 = ["4", "2"] | |
| Array.prototype.size = function() { return this.length; } | |
| var a2 = ["s", "y", "n", "b", "i", "o", "z"] | |
| a1.size() | |
| => 2 | |
| a2.size() | |
| => 7 |
This file contains hidden or 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
| [...].forty_two # Retourne le 42éme élément du tableau |
This file contains hidden or 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
| def colors(size) | |
| 1.upto(size).inject([]) { |colors, index| | |
| r, g, b = yield | |
| colors << "#%02x%02x%02x" % [r, g, b] | |
| } | |
| end | |
| def hsv_to_rgb(h, s, v) | |
| h_i = (h * 6).to_i | |
| f = h * 6 - h_i |
NewerOlder