るりまサーチ

最速Rubyリファレンスマニュアル検索!
434件ヒット [1-100件を表示] (0.083秒)
トップページ > クエリ:self[x] > クエリ:t[x] > クエリ:**[x]

別のキーワード

  1. object yield_self
  2. _builtin yield_self
  3. _builtin self
  4. tracepoint self
  5. codeobject document_self

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

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

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

...)を計算します。

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

//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)...
...整数になりそうなとき、警告を出したうえで Float::INFINITY を返します。

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

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

@see BigDecimal#powe...

Matrix#**(n) -> Matrix (21216.0)

self の n 乗を返します。

...
self
の n 乗を返します。

@param n べき数の指定
@raise ExceptionForMatrix::ErrNotRegular n が 0 以下で、行列が正則でない場合に発生します...

Rational#**(rhs) -> Numeric (21106.0)

@todo

...@todo

self
のべき乗を返します。 Rational になるようであれば Rational で返します。...

Object#yield_self -> Enumerator (9260.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Object#yield_self {|x| ... } -> object (9260.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
"my string".yield_self {|s| s.upcase } # => "MY STRING"
3.next.yield_self {|x| x**x }.to_s # => "256"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

絞り込み条件を変える

IO#set_encoding(ext_enc, int_enc, **opts) -> self (6505.0)

IO のエンコーディングを設定します。

...ーディングを内部エンコーディングに変換する際の
オプションを指定します。
詳しくは String#encode を参照してください。

@param enc_str エンコーディングを表す文字列を指定します。"A:B" のようにコロンで区切られた...
...表します。

@param ext_enc 外部エンコーディングを表す文字列か Encoding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換...
...のオプション
例:
io = File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...

Pathname#write(string, offset=nil, **opts) -> Integer (6313.0)

...IO.write(self.to_s, string, offset, **opts)と同じです。

@see IO.write...

IO#set_encoding(enc_str, **opts) -> self (6305.0)

IO のエンコーディングを設定します。

...ーディングを内部エンコーディングに変換する際の
オプションを指定します。
詳しくは String#encode を参照してください。

@param enc_str エンコーディングを表す文字列を指定します。"A:B" のようにコロンで区切られた...
...表します。

@param ext_enc 外部エンコーディングを表す文字列か Encoding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換...
...のオプション
例:
io = File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...

IO#set_encoding(ext_enc) -> self (6305.0)

IO のエンコーディングを設定します。

...ーディングを内部エンコーディングに変換する際の
オプションを指定します。
詳しくは String#encode を参照してください。

@param enc_str エンコーディングを表す文字列を指定します。"A:B" のようにコロンで区切られた...
...表します。

@param ext_enc 外部エンコーディングを表す文字列か Encoding オブジェクトを指定します。

@param int_enc 内部エンコーディングを表す文字列か Encoding オブジェクトを指定します。
@param opts エンコーディング変換...
...のオプション
例:
io = File.open(file)
io.set_encoding("ASCII-8BIT", "EUC-JP")...

Object#yield_self -> Enumerator (6254.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

絞り込み条件を変える

Object#yield_self {|x| ... } -> object (6254.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...
self
を引数としてブロックを評価し、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すの...
...です。

//emlist[メソッドチェインのパイプライン][ruby]{
require 'open-uri'
require 'json'

construct_url(arguments).
yield_self {|url| URI(url).read }.
yield_self {|response| JSON.parse(response) }
//}

ブロックなしで呼び出されたときは Enumerator を返します...
...
例えば条件によって値を捨てるのに使えます。

//emlist[][ruby]{
# 条件にあうので何もしない
1.yield_self.detect(&:odd?) # => 1
# 条件に合わないので値を捨てる
2.yield_self.detect(&:odd?) # => nil
//}

@see Object#tap...

Enumerable#inject(init = self.first) {|result, item| ... } -> object (6220.0)

リストのたたみこみ演算を行います。

...リストのたたみこみ演算を行います。

最初に初期値 init self の最初の要素を引数にブロックを実行します。
2 回目以降のループでは、前のブロックの実行結果と
self
の次の要素を引数に順次ブロックを実行します。
そう...
...て最後の要素まで繰り返し、最後のブロックの実行結果を返します。

要素が存在しない場合は init を返します。

初期値 init を省略した場合は、
最初に先頭の要素と 2 番目の要素をブロックに渡します。
また要素が 1 つし...
...が呼ばれます。

//emlist[例][ruby]{
# 合計を計算する。
p [2, 3, 4, 5].inject {|result, item| result + item } #=> 14

# 自乗和を計算する。初期値をセットする必要がある。
p [2, 3, 4, 5].inject(0) {|result, item| result + item**2 } #=> 54
//}

この式は...

Array#to_csv(**options) -> String (6216.0)

CSV.generate_line(self, options) と同様です。

...generate_line(self, options) と同様です。

Array オブジェクトを 1 行の CSV 文字列に変換するためのショートカットです。

@param options CSV.generate_line と同様のオプションを指定します。

//emlist[][ruby]{
require 'csv'

p [1, 'Matz', :Ruby, Date.new...
...(1965, 4, 14)].to_csv # => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}


@see CSV.generate_line...
...4)].to_csv # => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}

Ruby 3.0 (CSV 3.1.9) から、次のオプションが使えるようになりました。

//emlist[][...
...ruby]{
require 'csv'

puts [1, nil].to_csv # => 1,
puts [1, nil].to_csv(write_nil_value: "N/A") # => 1,N/A
puts [2, ""].to_csv # => 2,""
puts [2, ""].to_csv(write_empty_value: "BLANK") # => 2,BLANK
//}

@see CSV.generate_line...
<< 1 2 3 ... > >>