"Yukihiro Matsumoto" <matz / ruby-lang.org> wrotes

> |My question still remains - why? Although I agree that this may be
> |convenient in some cases it contradicts the "Principle of Least Surprise"
> |(at least for me). Or else, why isn't it implemented the same way for
hashes
> |too?
>
> (a) because I thought it was useful (note: I don't claim I've been right).
>
> (b) claiming PoLS is not allowed to complain about my decision. It's
>     spared for the dictator. ;-)

Ok, then I will complain that it _follows_ the principle of maximum surprise
;-)

> So let's not talk about PoLS, but talk about which is more useful.

In my opinion it should at least be consistent for similar objects. So
either 'to_s' should be used in every case, or 'puts' should handle all
containers the same (e.g. by using 'each' to interate through entries and
display them line by line). I would prefer the first solution because it
would give more flexibility, like redefining 'to_s' as in my example.

Regards,
Elmar