@@ -648,36 +648,22 @@ set_i_to_a(VALUE set)
648648
649649/*
650650 * call-seq:
651- * to_set(klass = Set, *args, &block) -> self or new_set
651+ * to_set(&block) -> self or new_set
652652 *
653- * Without arguments, returns +self+ (for duck-typing in methods that
654- * accept "set, or set-convertible" arguments) .
653+ * Without a block, if +self+ is an instance of +Set+, returns +self+.
654+ * Otherwise, calls <tt>Set.new(self, &block)</tt> .
655655 *
656656 * A form with arguments is _deprecated_. It converts the set to another
657657 * with <tt>klass.new(self, *args, &block)</tt>.
658658 */
659659static VALUE
660- set_i_to_set (int argc , VALUE * argv , VALUE set )
660+ set_i_to_set (VALUE set )
661661{
662- VALUE klass ;
663-
664- if (argc == 0 ) {
665- klass = rb_cSet ;
666- argv = & set ;
667- argc = 1 ;
668- }
669- else {
670- rb_warn_deprecated ("passing arguments to Set#to_set" , NULL );
671- klass = argv [0 ];
672- argv [0 ] = set ;
673- }
674-
675- if (klass == rb_cSet && rb_obj_is_instance_of (set , rb_cSet ) &&
676- argc == 1 && !rb_block_given_p ()) {
662+ if (rb_obj_is_instance_of (set , rb_cSet ) && !rb_block_given_p ()) {
677663 return set ;
678664 }
679665
680- return rb_funcall_passing_block (klass , id_new , argc , argv );
666+ return rb_funcall_passing_block (rb_cSet , id_new , 0 , NULL );
681667}
682668
683669/*
@@ -2292,7 +2278,7 @@ Init_Set(void)
22922278 rb_define_method (rb_cSet , "superset?" , set_i_superset , 1 );
22932279 rb_define_alias (rb_cSet , ">=" , "superset?" );
22942280 rb_define_method (rb_cSet , "to_a" , set_i_to_a , 0 );
2295- rb_define_method (rb_cSet , "to_set" , set_i_to_set , -1 );
2281+ rb_define_method (rb_cSet , "to_set" , set_i_to_set , 0 );
22962282
22972283 /* :nodoc: */
22982284 VALUE compat = rb_define_class_under (rb_cSet , "compatible" , rb_cObject );
0 commit comments