
Issue #21390 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Assigned to Closed Implemented in commit:0b07d2a1e32a456fc302c8d970fa85782bdb98ce ---------------------------------------- Feature #21390: Deprecate passing arguments to Set#to_set and Enumerable#to_set https://bugs.ruby-lang.org/issues/21390#change-113649 * Author: jeremyevans0 (Jeremy Evans) * Status: Closed * Assignee: knu (Akinori MUSHA) ---------------------------------------- Array#to_a, Hash#to_h, Enumerable#to_a, and Enumerable#to_h do not allow you to specify subclasses. This has undesired behavior when passing non-Set subclasses. All of these are currently allowed, and none make sense: ```ruby enum = [1,2,3].to_enum enum.to_set(Hash) enum.to_set(Struct.new("A", :a)) enum.to_set(ArgumentError) enum.to_set(Thread){} ``` Users who want to create instances of a subclass of Set from an enumerable should pass the enumerable to SetSubclass.new instead of using to_set, similar to how they would have to handle subclasses of Array or Hash. I've submitted a pull request that implements this: https://github.com/ruby/ruby/pull/13489 With the pull request, block arguments are still allowed (no warning). Positional and keyword argument use results in a deprecation warning. I would like to deprecate this in Ruby 3.5 (next feature release), and remove it in Ruby 3.6 (following feature release). -- https://bugs.ruby-lang.org/