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

访问量: 1630

参考: 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 )

订阅/RSS Feed

Subscribe

分类/category