I'm looking at Hash docs for has_value? and value?. However the link for value? leads to duplicate information about has_value?.
value? seems to work identically to has_value? (Ruby 3.02).
Does this mean value? is becoming deprecated or is this a documentation error?
CodePudding user response:
You can check if they are identical by comparing their method objects:
Hash.instance_method(:value?) == Hash.instance_method(:has_value?)
#=> true
UnboundMethod#== returns true if the methods refer to the same implementation.
Does this mean value? is becoming deprecated or is this a documentation error?
It seems to be a documentation error. The docs from the official website are more explicit regarding the alias:
https://docs.ruby-lang.org/en/3.0.0/Hash.html#method-i-has_value-3F
has_value?(value) → true or falseReturns
trueifvalueis a value inself, otherwisefalse.Also aliased as:
value?
However, the entry for value? doesn't have a heading: (the bold value?(value) → true or false part is missing)
https://docs.ruby-lang.org/en/3.0.0/Hash.html#method-i-value-3F
Returns
trueifvalueis a value inself, otherwisefalse.Alias for:
has_value?
