Skip to content

Commit

Permalink
Documented Ops.get.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Sep 12, 2014
1 parent ae37ba5 commit 4a65a65
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/ruby/yast/ops.rb
Expand Up @@ -65,10 +65,29 @@ def self.get_#{type}(object, indexes, default=nil, &block)
# @deprecated Use the native Ruby operator `[]`
#
# Gets value from *object* at *indexes*.
# In case value is not found, then return *default* value.
# Eager to return *default* at slightest provocation.
#
# **Replacement**
#
# Consider using
#
# - `object[index]`
# - `object[i1][i2]`
# - `object.fetch(index)`
# - `object.fetch(index, default)`
# - `object[index] || default` if the value cannot be `false` or `nil`
#
# @param object [Array, Hash, Yast::Term]
# @param indexes Usually a scalar, but also an array of scalars
# to recursively descend into *object*
# @param default the default value returned (via {deep_copy}) for any error;
# also may be a **block**
# @param skip_frames [Integer] private, how many caller frames to skip
# when reporting warnings or exceptions (0 by default)
# when reporting warnings or exceptions
#
# @return The value in *object* at *indexes*, if it exists.
# The *default* value if *object*, *indexes* are nil, have wrong type,
# or *indexes* does not exist in *object*.
def self.get (object, indexes, default=nil, skip_frames = 0)
res = object
default = Yast.deep_copy(default)
Expand Down

0 comments on commit 4a65a65

Please sign in to comment.