Method: Kernel#Hash
- Defined in:
- object.c
#Hash(object) ⇒ Object
Returns a hash converted from object.
-
If
objectis:-
A hash, returns
object. -
An empty array or
nil, returns an empty hash.
-
-
Otherwise, if
object.to_hashreturns a hash, returns that hash. -
Otherwise, returns TypeError.
Examples:
Hash({foo: 0, bar: 1}) # => {:foo=>0, :bar=>1}
Hash(nil) # => {}
Hash([]) # => {}
3946 3947 3948 3949 3950 |
# File 'object.c', line 3946 static VALUE rb_f_hash(VALUE obj, VALUE arg) { return rb_Hash(arg); } |