copy documentation comment from CRuby
INOUE Yasuyuki
9 years ago
1 | 1 | |
2 | 2 | # ISO does not define Hash#each_pair, so each_pair is defined in gem. |
3 | 3 | alias each_pair each |
4 | ||
5 | ## | |
6 | # call-seq: | |
7 | # Hash[ key, value, ... ] -> new_hash | |
8 | # Hash[ [ [key, value], ... ] ] -> new_hash | |
9 | # Hash[ object ] -> new_hash | |
10 | # | |
11 | # Creates a new hash populated with the given objects. | |
12 | # | |
13 | # Similar to the literal <code>{ _key_ => _value_, ... }</code>. In the first | |
14 | # form, keys and values occur in pairs, so there must be an even number of | |
15 | # arguments. | |
16 | # | |
17 | # The second and third form take a single argument which is either an array | |
18 | # of key-value pairs or an object convertible to a hash. | |
19 | # | |
20 | # Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200} | |
21 | # Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200} | |
22 | # Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200} | |
23 | # | |
4 | 24 | |
5 | 25 | def self.[](*object) |
6 | 26 | o = object[0] |