Method: Set#inspect

Defined in:
lib/set.rb

#inspectObject Also known as: to_s

Returns a string containing a human-readable representation of the set (“#<Set: element2, …>”).


652
653
654
655
656
657
658
659
660
661
662
663
664
665
# File 'lib/set.rb', line 652

def inspect
  ids = (Thread.current[InspectKey] ||= [])

  if ids.include?(object_id)
    return sprintf('#<%s: {...}>', self.class.name)
  end

  ids << object_id
  begin
    return sprintf('#<%s: {%s}>', self.class, to_a.inspect[1..-2])
  ensure
    ids.pop
  end
end