class NilClass

Ruby’s core NilClass. See documentation for version 2.1.5, 2.0.0, or 1.9.3.

Public Instance Methods

try_rescue(*args, &block) click to toggle source

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
   # File lib/reactive_extensions/object/try_rescue.rb
62 def try_rescue(*args, &block)
63   nil 
64 end