るりまサーチ

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

別のキーワード

  1. _builtin exception
  2. exception exception
  3. thread abort_on_exception
  4. thread abort_on_exception=
  5. bigdecimal exception_zerodivide

ライブラリ

キーワード

検索結果

Kernel.#Integer(arg, base = 0, exception: true) -> Integer | nil (145.0)

引数を整数 (Fixnum,Bignum) に変換した結果を返します。

...) です。

@param exception false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。

@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッ...
...ブジェクトを引数に指定したか、to_int, to_i
が整数(Integerのサブクラス)を返さなかった場合に発生します。
@raise TypeError 引数に nil を指定した場合に発生します。

//emlist[例][ruby]{
p Integer(4) #=> 4
p Integer(4_000) #=> 4000...
...teger("1\n0") # `Integer': invalid value for Integer: "1\n0" (ArgumentError)
p Integer("hoge") # `Integer': invalid value for Integer: "hoge" (ArgumentError)
p Integer("") # `Integer': invalid value for Integer: "" (ArgumentError)
//}

@see String#hex,String#oct,String#to_i,Integer...

Kernel.#Float(arg, exception: true) -> Float | nil (133.0)

引数を浮動小数点数(Float)に変換した結果を返します。

...字列に対し String#to_f よりも厳密な変換を行います。

@param arg 変換対象のオブジェクトです。
@param exception false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。
@raise ArgumentError...
...整数や浮動小数点数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError nil またはメソッド to_f を持たないオブジェクトを引数に指定したか、
to_f が浮動小数点数を返さなかった場合に発生し...
...alid value for Float(): "0xa.a" (ArgumentError)
p Float(" \n10\s \t") #=> 10.0 # 先頭と末尾の空白類は無視される
p Float("1\n0") # invalid value for Float(): "1\n0" (ArgumentError)
p Float("") # invalid value for Float(): "" (ArgumentError)
//}

@see String#to_f,Float...