Sha256: d5d57f5ef817b3cb55411dcaaa39f6a7bab615b3e983e2c0408695ea79188bd6
Contents?: true
Size: 307 Bytes
Versions: 160
Compression:
Stored size: 307 Bytes
Contents
class Object # Tries the given methods and returns the first one to return a value, # ultimately returns nil if no value is found. def try(*methods) methods.each do |method| if self.respond_to?(method) val = send(method) return val if val end end nil end end
Version data entries
160 entries across 160 versions & 1 rubygems