irb(main):001:0> Hash["name","subbu","profession","programmer"]
=> {"name"=>"subbu", "profession"=>"programmer"}
irb(main):002:0> my_array = %w{ a b c d }
=> ["a", "b", "c", "d"]
irb(main):003:0> Hash[*my_array]
=> {"a"=>"b", "c"=>"d"}
Notes to self
Thursday, February 28, 2008
square brackets [] class method of Hash
[] class method of Hash converts an array into a hash.
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2008
(51)
-
▼
February
(12)
- square brackets [] class method of Hash
- Preventing sensitive data from being logged in Rai...
- Route Globbing
- String: extract a single character
- require and load won't reload the file with reload...
- Rails without a database
- eval
- binding in ruby
- ActiveRecord tricks - :include and :select options
- Convert String to Range
- Prevent a class from instantiating
- SQL joins explained
-
▼
February
(12)
No comments:
Post a Comment