るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.075秒)

別のキーワード

  1. kernel exec
  2. kernel spawn
  3. kernel system
  4. kernel open
  5. kernel gsub

ライブラリ

検索結果

Object#to_s -> String (32.0)

オブジェクトの文字列表現を返します。

...を返します。

Kernel
.#print や Kernel.#sprintf は文字列以外の
オブジェクトが引数に渡された場合このメソッドを使って文字列に変換し
ます。

//emlist[][ruby]{
class Foo
def initialize num
@num = num
end
end
it = Foo.new(40)

puts
it #=> #<Foo:0x2...
...b69110>

class Foo
def to_s
"Class:Foo Number:#{@num}"
end
end

puts
it #=> Class:Foo Number:40
//}

@see Object#to_str,Kernel.#String...