提交 c49409fa 编写于 作者: प्रथमेश Sonpatki

Merge pull request #25189 from xtian/patch-1

ActionController::Parameters: Fix #dig doc code
...@@ -441,12 +441,12 @@ def fetch(key, *args) ...@@ -441,12 +441,12 @@ def fetch(key, *args)
# Extracts the nested parameter from the given +keys+ by calling +dig+ # Extracts the nested parameter from the given +keys+ by calling +dig+
# at each step. Returns +nil+ if any intermediate step is +nil+. # at each step. Returns +nil+ if any intermediate step is +nil+.
# #
# params = ActionController::Parameters.new(foo: { bar: { baz: 1 } }) # params = ActionController::Parameters.new(foo: { bar: { baz: 1 } })
# params.dig(:foo, :bar, :baz) # => 1 # params.dig(:foo, :bar, :baz) # => 1
# params.dig(:foo, :zot, :xyz) # => nil # params.dig(:foo, :zot, :xyz) # => nil
# #
# params2 = ActionController::Parameters.new(foo: [10, 11, 12]) # params2 = ActionController::Parameters.new(foo: [10, 11, 12])
# params2.dig(:foo, 1) # => 11 # params2.dig(:foo, 1) # => 11
def dig(*keys) def dig(*keys)
convert_value_to_parameters(@parameters.dig(*keys)) convert_value_to_parameters(@parameters.dig(*keys))
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册