instance method
Kernel#String
(::string | ::_ToS string_like) -> ::String
String(object) → object or new_string
object.c
View on GitHub ↗
static VALUE
rb_f_string(VALUE obj, VALUE arg)
{
return rb_String(arg);
}
Returns a string converted from object.
Tries to convert object to a string using to_str first and to_s second:
Example
String([0, 1, 2]) # => "[0, 1, 2]" String(0..5) # => "0..5" String({foo: 0, bar: 1}) # => "{foo: 0, bar: 1}"
Raises TypeError if object cannot be converted to a string.