Search code examples
ruby

Ruby - equivalent of Python __str__() method?


In Ruby, is there the equivalent of the __str__() method that you can define on Python classes?


Solution

  • You could use to_s.

    http://briancarper.net/2006/09/26/ruby-to_s-vs-to_str/