るりまサーチ

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

検索結果

Object#to_s -> String (18120.0)

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

...使って文字列に変換し
ます。

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

puts it #=> #<Foo:0x2b69110>

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

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

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

String#%(args) -> String (13.0)

printf と同じ規則に従って args をフォーマットします。

...グ `-' と幅 の指定だけが意味を持ちます。

: s

文字列を出力します。

引数が String オブジェクトでなければ to_s メソッドにより文字列化
したものを引数として扱います。

: p

Object#inspect の結果を出力します。
//emlist[][r...
..."10.1"

p sprintf("%g", 10 ** 6) #=> "1e+06"
p sprintf("%g", 10 ** -5) #=> "1e-05"
//}
精度の省略値は 6 です。

無限大、NaN(Not a Number) に対する出力は以下のとおりです。
//emlist[][ruby]{
p sprintf("%f", 1.0/0) #=> "inf"
p sprintf("%f", -1.0/0) #=> "-inf"
p spri...