So you want something similar to x = obj.method || default? Ruby is the perfect language for creating your own upstream constructs:
class Object
def try_method(name, *args, &block)
self.respond_to?(name) ? self.send(name, *args, &block) : nil
end
end
p "Hello".try_method(:downcase) || "default"
p "hello".try_method(:not_existing) || "default"
, ? , Ick maybe - ( ):
p "hello".maybe_has_method.not_existing || "default"
: , , , , , . nil , , ? Ick : object_or_nil.maybe.method || default