Method: Set#to_set

Defined in:
lib/set.rb

#to_set(klass = Set, *args, &block) ⇒ Object

Returns self if no arguments are given. Otherwise, converts the set to another with ‘klass.new(self, *args, &block)`.

In subclasses, returns ‘klass.new(self, *args, &block)` unless overridden.


204
205
206
207
# File 'lib/set.rb', line 204

def to_set(klass = Set, *args, &block)
  return self if instance_of?(Set) && klass == Set && block.nil? && args.empty?
  klass.new(self, *args, &block)
end