Ruby - Classes and Objects
How do you correctly override the
to_s method in a Ruby class to return a custom string?to_s method in a Ruby class to return a custom string?to_s requires returning a string, not printing it.puts or print, which output to console but return nil or unexpected values.puts obj.to_s prints the returned string [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions