るりまサーチ

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

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Ripper#warning(fmt, *args) -> nil (18246.0)

解析した Ruby プログラムの中に重要な警告($-w が false の時だけ出 力される警告)を出力するようなものがあった場合に実行されます。

...解析した Ruby プログラムの中に重要な警告($-w が false の時だけ出
力される警告)を出力するようなものがあった場合に実行されます。

@
param fmt エラーメッセージのフォーマット文字列です。

@
param args エラーメッセージのフ...

Integer#**(other) -> Numeric (227.0)

算術演算子。冪(べき乗)を計算します。

...算子。冪(べき乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以...
...の数を指定した場合に発生します。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなと...
...き、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。


@
see BigDecimal#power...

Integer#pow(other) -> Numeric (227.0)

算術演算子。冪(べき乗)を計算します。

...算子。冪(べき乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以...
...の数を指定した場合に発生します。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなと...
...き、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。


@
see BigDecimal#power...

Integer#pow(other, modulo) -> Integer (227.0)

算術演算子。冪(べき乗)を計算します。

...算子。冪(べき乗)を計算します。

@
param other 二項演算の右側の引数(対象)
@
param modulo 指定すると、計算途中に巨大な値を生成せずに (self**other) % modulo と同じ結果を返します。
@
return 計算結果
@
raise TypeError 2引数 pow で Integer 以...
...の数を指定した場合に発生します。

//emlist[][ruby]{
2 ** 3 # => 8
2 ** 0 # => 1
0 ** 0 # => 1
3.pow(3, 8) # => 3
3.pow(3, -8) # => -5
3.pow(2, -2) # => -1
-
3.pow(3, 8) # => 5
-
3.pow(3, -8) # => -3
5.pow(2, -8) # => -7
//}

結果が巨大すぎる整数になりそうなと...
...き、警告を出したうえで Float::INFINITY を返します。

//emlist[計算を放棄して Float::INFINITY を返す例][ruby]{
p 100**9999999
# => warning: in a**b, b may be too big
# Infinity
//}

判定の閾値は変わりえます。


@
see BigDecimal#power...

String#to_f -> Float (179.0)

文字列を 10 進数表現と解釈して、浮動小数点数 Float に変換します。

...換できないような文字列がある場合、それより先の文字列は無視されます。

//emlist[][ruby]{
p "-10".to_f # => -10.0
p "10e2".to_f # => 1000.0
p "1e-2".to_f # => 0.01
p ".1".to_f # => 0.1

p "1_0_0".to_f # => 100.0 # 数値リテラルと同じように区切り...
...、0.0 を返します。
変換対象が空文字列のケースでも、0.0 を返します。

//emlist[][ruby]{
p "".to_f # => 0.0
p "nan".to_f # => 0.0
p "INF".to_f # => 0.0
p "-Inf".to_f # => 0.0
//}

変換後の Float が有限の値を取れないときは、Float::INFINITY を用...
...す。

//emlist[][ruby]{
#!ruby -W2

p ("10" * 1000).to_f # => Infinity
# warning: Float 10101010101010101010... out of range
//}

なお、このメソッドとは逆に、数値を文字列に変換するには
Kernel.#sprintf, String#%, Integer#to_s
を使用します。

@
see String#hex, Stri...

絞り込み条件を変える

Module#deprecate_constant(*name) -> self (167.0)

name で指定した定数を deprecate に設定します。 deprecate に設定した定数を参照すると警告メッセージが表示されます。

...表示されます。

Ruby
2.7.2 から Warning[:deprecated] のデフォルト値が false に変更になったため、
デフォルトでは警告が表示されません。

コマンドラインオプション(詳細はd:spec/rubycmd#cmd_option参照)で、
-w」か「-W2」などを指定...
...Warning[:deprecated] = true」で
変更すると表示されるようになります。

「$VERBOSE = true」は「Warning[:deprecated]」に影響しないため、
表示されるかどうかは変わりません。

@
param name 0 個以上の String か Symbol を指定します。

@
raise N...
...ameError 存在しない定数を指定した場合に発生します。

@
return self を返します。

//emlist[例][ruby]{
FOO = 123
Object.deprecate_constant(:FOO) # => Object

FOO
# warning: constant ::FOO is deprecated
# => 123

Object.deprecate_constant(:BAR)
# NameError: constant Object::B...

Hash#fetch(key) -> object (143.0)

key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。

...

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。

//emlist[例][ruby]{...
...o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
...wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...

Hash#fetch(key) {|key| ... } -> object (143.0)

key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。

...

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。

//emlist[例][ruby]{...
...o not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
...wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...

Hash#fetch(key, default) -> object (143.0)

key に関連づけられた値を返します。該当するキーが登録されてい ない時には、引数 default が与えられていればその値を、ブロッ クが与えられていればそのブロックを評価した値を返します。

...

@
param key 探索するキーを指定します。
@
param default 該当するキーが登録されていない時の返り値を指定します。
@
raise KeyError 引数defaultもブロックも与えられてない時、キーの探索に失敗すると発生します。

//emlist[例][ruby]{...
...wo not exist"
"#{key} not exist" # warning: block supersedes default value argument
} # 警告が表示される。

h.default = "default"
p h.fetch(:two) # エラー key not found (KeyError)
//}

@
see Hash#[]...
<< 1 2 > >>