1

私はルビーにまったく慣れていないので、この単純な問題をブロックしています。

私は次のハッシュを持っています:

theData"=>{"586"=>{"status"=>"0"},
           "585"=>{"status"=>"0"}}

次のハッシュを取得するために、各レベルに「current_editor」という行を追加したいと思います。

theData"=>{"586"=>{"status"=>"0", "current_editor" => "3"},
           "585"=>{"status"=>"0", "current_editor" => "3"}}

これどうやってするの?よろしくお願いします!

4

1 に答える 1

1
theData = {"586"=>{"status"=>"0"}, "585"=>{"status"=>"0"}}
theData.each{|k, v| theData[k]["current_editor"] = 3}
#=> {"586"=>{"status"=>"0", "current_editor"=>3}, 
#=>  "585"=>{"status"=>"0", "current_editor"=>3}} 
于 2011-10-03T15:54:55.423 に答える