Commit 5f16c417 authored by INOUE Yasuyuki's avatar INOUE Yasuyuki

copy documentation comment from CRuby

parent d30aadf3
......@@ -3,6 +3,26 @@ class Hash
# ISO does not define Hash#each_pair, so each_pair is defined in gem.
alias each_pair each
##
# call-seq:
# Hash[ key, value, ... ] -> new_hash
# Hash[ [ [key, value], ... ] ] -> new_hash
# Hash[ object ] -> new_hash
#
# Creates a new hash populated with the given objects.
#
# Similar to the literal <code>{ _key_ => _value_, ... }</code>. In the first
# form, keys and values occur in pairs, so there must be an even number of
# arguments.
#
# The second and third form take a single argument which is either an array
# of key-value pairs or an object convertible to a hash.
#
# Hash["a", 100, "b", 200] #=> {"a"=>100, "b"=>200}
# Hash[ [ ["a", 100], ["b", 200] ] ] #=> {"a"=>100, "b"=>200}
# Hash["a" => 100, "b" => 200] #=> {"a"=>100, "b"=>200}
#
def self.[](*object)
o = object[0]
if o.respond_to?(:to_hash)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment