From: "jeremyevans0 (Jeremy Evans) via ruby-core" Date: 2025-06-01T03:38:59+00:00 Subject: [ruby-core:122356] [Ruby Feature#21390] Deprecate passing arguments to Set#to_set and Enumerable#to_set Issue #21390 has been reported by jeremyevans0 (Jeremy Evans). ---------------------------------------- Feature #21390: Deprecate passing arguments to Set#to_set and Enumerable#to_set https://bugs.ruby-lang.org/issues/21390 * Author: jeremyevans0 (Jeremy Evans) * Status: Open ---------------------------------------- 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/