End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Kernel#String
String(arg) → string
object.c
View on GitHub ↗
static VALUE
rb_f_string(VALUE obj, VALUE arg)
{
return rb_String(arg);
}
Returns arg as a String.
First tries to call its to_str method, then its to_s method.
Example
String(self) #=> "main" String(self.class) #=> "Object" String(123456) #=> "123456"