Class: NilClass
Overview
Instance Method Summary collapse
-
#try_rescue(*args, &block) ⇒ Object
The
#try_rescue
method extends ReactiveSupport’s#try
method so it rescues NoMethodErrors and TypeErrors as well as returningnil
when called on anil
value.
Instance Method Details
#try_rescue(*args, &block) ⇒ Object
The #try_rescue
method extends ReactiveSupport’s #try
method so it rescues NoMethodErrors and TypeErrors as well as returning nil
when called on a nil
value.
Like the #try
method, #try_rescue
takes 1 or more arguments. The first argument is the method to be called on the calling object, passed as a symbol. The others are zero or more arguments that will be passed through to that method, and an optional block to be likewise passed through.
When called on NilClass, #try_rescue
always returns nil.
Example:
foo = nil
foo.try_rescue(:has_key?, :bar) # => nil
62 63 64 |
# File 'lib/reactive_extensions/object/try_rescue.rb', line 62 def try_rescue(*args, &block) nil end |