instance method
Set#inspect
() -> ::String
inspect → new_string
set.c
View on GitHub ↗
static VALUE
set_i_inspect(VALUE set)
{
return rb_exec_recursive(set_inspect, set, 0);
}
Returns a new string containing the set entries:
Example
s = Set.new s.inspect # => "Set[]" s.add(1) s.inspect # => "Set[1]" s.add(2) s.inspect # => "Set[1, 2]"
Related: see Methods for Converting.
Ruby version changes
-
4.0
-
Set#inspectnow uses a simpler display, similar to literal arrays. (e.g.,Set[1, 2, 3]instead of#<Set: {1, 2, 3}>). [Feature #21389]
-