I’ve been experimenting and find that I like redefining Object’s to_s methods.
Is this a bad idea or is it good practice?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, you should feel free to override
to_s– there are no ill side-effects. As long as your newto_sis more informative than the built-in (not exactly a high standard there), you’re in the clear.And they help make your test failures read better – sometimes by a lot – which is never a bad thing. Go for it!