Testing Whether an Object Is String-like : respond_to « Reflection « Ruby
- Ruby
- Reflection
- respond_to
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
Related examples in the same category