Mega Code Archive
Categories
/
Ruby
/
Reflection
Testing Whether an Object Is String-like
'A string'.respond_to? :to_str # => true Exception.new.respond_to? :to_str # => true 4.respond_to? :to_str # => false