M
Mark Volkmann
Here's what I've learned so far.
1) Every object has to_s because Object provides a default implementation.
2) Some classes override to_s to return a more useful String.
3) to_str should only be implemented in classes whose objects can
logically be used as Strings.
If you're going to implement to_str in a class, is there a reason why
it might return something different than to_s? Is one considered a
human-readable representation and the other something else?
Isn't "can be logically used as Strings" a somewhat subjective thing?
--=20
R. Mark Volkmann
Partner, Object Computing, Inc.
1) Every object has to_s because Object provides a default implementation.
2) Some classes override to_s to return a more useful String.
3) to_str should only be implemented in classes whose objects can
logically be used as Strings.
If you're going to implement to_str in a class, is there a reason why
it might return something different than to_s? Is one considered a
human-readable representation and the other something else?
Isn't "can be logically used as Strings" a somewhat subjective thing?
--=20
R. Mark Volkmann
Partner, Object Computing, Inc.