instance method
Set#to_set
() -> ::Set[A]
[T] () { (A) -> T } -> ::Set[T]
to_set(klass = Set, *args, &block) → self or new_set
set.c
View on GitHub ↗
static VALUE
set_i_to_set(int argc, VALUE *argv, VALUE set)
{
VALUE klass;
if (argc == 0) {
klass = rb_cSet;
argv = &set;
argc = 1;
}
else {
rb_warn_deprecated("passing arguments to Set#to_set", NULL);
klass = argv[0];
argv[0] = set;
}
if (klass == rb_cSet && rb_obj_is_instance_of(set, rb_cSet) &&
argc == 1 && !rb_block_given_p()) {
return set;
}
return rb_funcall_passing_block(klass, id_new, argc, argv);
}
Without arguments, returns self (for duck-typing in methods that accept “set, or set-convertible” arguments).
A form with arguments is deprecated. It converts the set to another with klass.new(self, *args, &block).
Ruby version changes
-
4.0
-
Passing arguments to
Set#to_setandEnumerable#to_setis now deprecated. [Feature #21390]
-