Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby - equivalent of Python __str__() method?

Tags:

ruby

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

like image 977
readonly Avatar asked Sep 25 '08 18:09

readonly


1 Answers

You could use to_s.

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

like image 136
GEOCHET Avatar answered Sep 18 '22 15:09

GEOCHET