What do you want to do?
If you want a list of the elements, use to_a.
If you want to see what elements it has, use inspect.
I'm printing several sets in my erb. It would be nice have such to_s behaviour by default, eliminating the need to call to_a on each of them before print
What do you want to do?
If you want a list of the elements, use to_a.
If you want to see what elements it has, use inspect.
Isn't it just a decent behavior for any value object to have a readable to_s representation?.. Say, for cases like puts-debugging (puts "Comparing #{set1} to #{set2}...") or developer-friendly error messages (raise "Input was expected to have 4 elements, #{set} received").
I have no idea why Set behaves that way, perhaps there is a clear reason.
I can however had understand razor too - without knowing the context or
really having a lot of experience with Set mayself, to me the behaviour
of Array seems "more useful" by default. But again, I have no real idea
about this so neither can I say good or bad if it would be changed - I
really don't know. I only use Arrays, barely ever Set myself. :)