Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Ruby on Rails 3.2.2,我正在寻找一种与except散列(except文档)相反的方法,可能是一种only方法。是否有某种方法或简单的方法可以返回仅包含给定键的哈希?
except
only
# Example, 'only' method as opposite to the 'except' @person.update_attributes(params[:person].only(:name, :surname))
我认为您正在寻找的是slice,它将返回仅包含给定键的哈希。
slice