Module: RubyTry
Instance Method Summary collapse
Instance Method Details
#try?(*args) ⇒ Boolean
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ruby-try.rb', line 2 def try?(*args) if args.first =~ /[?]$/ if respond_to?(args.first) public_send(*args) else false end else raise ArgumentError, "For non-boolean methods use only try()" end end |