Codebase list mruby / 5f16c41
copy documentation comment from CRuby INOUE Yasuyuki 9 years ago
1 changed file(s) with 20 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
11
22 # ISO does not define Hash#each_pair, so each_pair is defined in gem.
33 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 #
424
525 def self.[](*object)
626 o = object[0]