メモ。Ruby 1.9 なら標準で、1.8.7 環境なら active_support で。
require 'active_support/core_ext/enumerable'
で。
{:foo => '1', :bar => '2'}.each_with_object({}) {|(key, value), object|
object[key] = value.to_i
}
# => {:foo=>1, :bar=>2}
Go to list of users who liked
More than 5 years have passed since last update.
メモ。Ruby 1.9 なら標準で、1.8.7 環境なら active_support で。
require 'active_support/core_ext/enumerable'
で。
{:foo => '1', :bar => '2'}.each_with_object({}) {|(key, value), object|
object[key] = value.to_i
}
# => {:foo=>1, :bar=>2}
Register as a new user and use Qiita more conveniently
Go to list of users who liked