Back

在Rails中,删除某个hash中的多个key (delete multiple keys from a hash in Rails )

发布时间: 2013-01-30 02:09:00

参考: http://stackoverflow.com/questions/1560572/ruby-delete-multiple-hash-keys

sg552@youku:/sg552/workspace/postman$ bundle exec rails c
Loading development environment (Rails 3.2.9)
>> apple = {:shape => 'ball', :taste => 'sweet', :color => 'red' }
=> {:shape=>"ball", :taste=>"sweet", :color=>"red"}

>> apple.except(:shape, :color)
=> {:taste=>"sweet"}

结论: ActiveSupport 需要我们挖掘的东西太多了, 有空时务必看一下 ( we need to keep learning ActiveSupport )

Back