Issue #13676 has been updated by shevegen (Robert A. Heiler).


I have no pro or con opinion. I did however had want to compare Set to Array and the two behave differently.

    require 'pp'
    require 'set'

    s1 = Set.new
    s1<<'tic'<<'tac'
    puts s1.to_s
    pp s1

    array = Array.new
    array << 'tic' << 'tac'
    puts array.to_s
    pp array

    # Output:
    #
    # <Set:0x810460c4>
    # <Set: {"tic", "tac"}>
    # ["tic", "tac"]
    # ["tic", "tac"]

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. :)

----------------------------------------
Feature #13676: to_s method is not overriden for Set
https://bugs.ruby-lang.org/issues/13676#change-65454

* Author: razor (Marat Chardymov)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
When I call

~~~ ruby
s1 = Set.new
s1<<'tic'<<'tac'
s1.to_s
~~~

I'd expect ['tic', 'tac'] values being printed, not "#<Set:0x0055f331076348>"




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>