Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Set#inspect
() -> ::String
inspect → string
set.c
View on GitHub ↗
static VALUE
set_i_inspect(VALUE set)
{
return rb_exec_recursive(set_inspect, set, 0);
}
Returns a string representation of self:
Example
Set[*%w[foo bar], {foo: 0, bar: 1}].inspect # => "Set[\"foo\", \"bar\", {foo: 0, bar: 1}]"
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]
-