るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Hash#values -> [object] (32209.0)

ハッシュの全値の配列を返します。

...ハッシュの全値の配列を返します。

//emlist[例][ruby]{
h1 = { "a" => 100, 2 => ["some"], :c => "c" }
p h1.values #=> [100, ["some"], "c"]
//}

@see Hash#keys,Hash#to_a...

ENV.values -> [String] (32203.0)

環境変数の全値の配列を返します。

環境変数の全値の配列を返します。

Struct#values -> [object] (26203.0)

構造体のメンバの値を配列にいれて返します。

...構造体のメンバの値を配列にいれて返します。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345).to_a
# => ["Joe Smith", "123 Maple, Anytown NC", 12345]
//}

[注意] 本メソッドの記述は Struct の下...
...位クラスのインスタンスに対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。...

Enumerator#peek_values -> Array (20327.0)

Enumerator#next_values のように「次」のオブジェクトを 配列で返しますが、列挙状態を変化させません。

...
E
numerator#next_values のように「次」のオブジェクトを
配列で返しますが、列挙状態を変化させません。

E
numerator#next, Enumerator#next_values のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり...
...eration 例外を発生します。

このメソッドは Enumerator#next_values と同様
yield

yield nil
を区別するために使えます。

//emlist[例][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
e
nd
e
= o.to_enum
p e.peek_values #=> []
e
.next
p e.peek_value...
...s #=> [1]
p e.peek_values #=> [1]
e
.next
p e.peek_values #=> [1, 2]
e
.next
p e.peek_values # raises StopIteration
//}

@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values...

Enumerator#next_values -> Array (20323.0)

「次」のオブジェクトを配列で返します。

...ェクトを配列で返します。

E
numerator#next とほぼ同様の挙動をします。終端まで到達した場合は
StopIteration 例外を発生させます。

このメソッドは、
yield

yield nil
を区別するために使えます。

next メソッドによる外部列...
...IO#each_line のようにおおもとの列挙メカニズムが副作用を
伴っている場合には影響があり得ます。

//emlist[例: next と next_values の違いを][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
yield nil
yield [1, 2]
e
nd
e
= o.to_enum
p e.next_...
...ues
p e.next_values
p e.next_values
p e.next_values
p e.next_values
e
= o.to_enum
p e.next
p e.next
p e.next
p e.next
p e.next

## yield args next_values next
# yield [] nil
# yield 1 [1] 1
# yield 1, 2 [1, 2] [1, 2]
# yie...

絞り込み条件を変える

Array#values_at(*selectors) -> Array (20287.0)

引数で指定されたインデックスに対応する要素を配列で返します。インデッ クスに対応する値がなければ nil が要素になります。

...electors インデックスを整数もしくは整数の Range で指定します。

//emlist[例][ruby]{
ary = %w( a b c d e )
p ary.values_at( 0, 2, 4 ) #=> ["a", "c", "e"]
p ary.values_at( 3, 4, 5, 6, 35 ) #=> ["d", "e", nil, nil, nil]
p ary.values_at( 0, -1, -2 ) #=> ["a", "e...
...ary.values_at( -4, -5, -6, -35 ) #=> ["b", "a", nil, nil]
p ary.values_at( 1..2 ) #=> ["b", "c"]
p ary.values_at( 3..10 ) #=> ["d", "e", nil, nil, nil, nil, nil, nil]
p ary.values_at( 6..7 ) #=> [nil, nil]
p ary.values_at( 0, 3..5 ) #=> ["a", "d", "e", n...

Hash#transform_values! -> Enumerator (20234.0)

すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。

...ーは変化しません。

@return transform_values! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_values! {|v| v * v + 1 } #=> { a: 2...
..., b: 5, c: 10 }
h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "2.0", b: "5.1", c: "10.2" }
//}

@see Hash#transform_values...
..., b: 5, c: 10 }
h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "2.0", b: "5.1", c: "10.2" }
//}

@see Hash#transform_values
@see Hash#transform_keys
@see Hash#transform_keys!...

Hash#transform_values! {|value| ... } -> self (20234.0)

すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。

...ーは変化しません。

@return transform_values! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_values! {|v| v * v + 1 } #=> { a: 2...
..., b: 5, c: 10 }
h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "2.0", b: "5.1", c: "10.2" }
//}

@see Hash#transform_values...
..., b: 5, c: 10 }
h.transform_values!(&:to_s) #=> { a: "2", b: "5", c: "10" }
h.transform_values!.with_index {|v, i| "#{v}.#{i}" }
#=> { a: "2.0", b: "5.1", c: "10.2" }
//}

@see Hash#transform_values
@see Hash#transform_keys
@see Hash#transform_keys!...

MatchData#values_at(*index) -> [String] (20233.0)

正規表現中の n 番目の括弧にマッチした部分文字列の配列を返します。

...全体を表します。

@param index インデックスを整数またはシンボル(名前付きキャプチャの場合)で 0 個以上指定します。

//emlist[例][ruby]{
m = /(foo)(bar)(baz)/.match("foobarbaz")
# same as m.to_a.values_at(...)
p m.values_at(0, 1, 2, 3, 4) # => ["fooba...
...z", "foo", "bar", "baz", nil]
p m.values_at(-1, -2, -3, -4, -5) # => ["baz", "bar", "foo", nil, nil]

m = /(?<a>\d+) *(?<op>[+\-*\/]) *(?<b>\d+)/.match("1 + 2")
m.to_a # => ["1 + 2", "1", "+", "2"]
m.values_at(:a, :b, :op) # => ["1", "2", "+"]
//}

@see Array#values_at, Array#[]...

Hash#fetch_values(key, ...) -> [object] (20228.0)

引数で指定されたキーに関連づけられた値の配列を返します。

...ックが与えられていない時は
KeyError が発生します。

self にデフォルト値が設定されていても無視されます(挙動に変化がありません)。

@param key 探索するキーを任意個指定します。

@raise KeyError ブロックが与えられてない...
...

//emlist[例][ruby]{
h = { "cat" => "feline", "dog" => "canine", "cow" => "bovine" }

h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]...
...//}

@see Hash#values_at, Hash#fetch...

絞り込み条件を変える

<< 1 2 3 ... > >>