Ruby: Easiest Way to Filter Hash Keys?

前端 未结 13 1198

I have a hash that looks something like this:

params = { :irrelevant => \"A String\",
           :choice1 => \"Oh look, another one\",
           :choi         


        
13条回答
  •  情歌与酒
    2020-11-30 18:35

    The easiest way is to include the gem 'activesupport' (or gem 'active_support').

    params.slice(:choice1, :choice2, :choice3)

提交回复
热议问题