214件ヒット
[1-100件を表示]
(0.052秒)
別のキーワード
クラス
- Array (14)
-
CSV
:: Table (36) - Enumerator (24)
- Hash (92)
- MatchData (12)
-
Resolv
:: DNS (12) - Struct (24)
キーワード
- [] (12)
-
delete
_ if (12) - each (12)
-
fetch
_ values (22) -
next
_ values (12) -
peek
_ values (12) - timeouts= (12)
-
transform
_ values (18) -
transform
_ values! (18) -
values
_ at (60)
検索結果
先頭5件
-
Hash
# values -> [object] (24220.0) -
ハッシュの全値の配列を返します。
...ハッシュの全値の配列を返します。
//emlist[例][ruby]{
h1 = { "a" => 100, 2 => ["some"], :c => "c" }
p h1.values #=> [100, ["some"], "c"]
//}
@see Hash#keys,Hash#to_a... -
Struct
# values -> [object] (18214.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 の下... -
Hash
# transform _ values! {|value| . . . } -> self (12346.0) -
すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。
...nsform_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......_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| . . . } -> Hash (12340.0) -
すべての値に対してブロックを呼び出した結果で置き換えたハッシュを返します。 キーは変化しません。
...ブジェクトを
返します。
//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: "1", b: "2", c: "3" }
h.transform_values.with_index {|v, i| "#{v}.#{i}" }......#=> { a: "1.0", b: "2.1", c: "3.2" }
//}
@see Hash#transform_values!......#=> { a: "1.0", b: "2.1", c: "3.2" }
//}
@see Hash#transform_values!
@see Hash#transform_keys
@see Hash#transform_keys!... -
Enumerator
# peek _ values -> Array (12284.0) -
Enumerator#next_values のように「次」のオブジェクトを 配列で返しますが、列挙状態を変化させません。
...Enumerator#next_values のように「次」のオブジェクトを
配列で返しますが、列挙状態を変化させません。
Enumerator#next, Enumerator#next_values のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり......r#next_values と同様
yield
と
yield nil
を区別するために使えます。
//emlist[例][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
end
e = o.to_enum
p e.peek_values #=> []
e.next
p e.peek_values #=> [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... -
Array
# values _ at(*selectors) -> Array (12262.0) -
引数で指定されたインデックスに対応する要素を配列で返します。インデッ クスに対応する値がなければ nil が要素になります。
...list[例][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", "d"]
p 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", nil]
//}... -
Enumerator
# next _ values -> Array (12262.0) -
「次」のオブジェクトを配列で返します。
...values の違いを][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
yield nil
yield [1, 2]
end
e = o.to_enum
p e.next_values
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_value......[1] 1
# yield 1, 2 [1, 2] [1, 2]
# yield nil [nil] nil
# yield [1, 2] [[1, 2]] [1, 2]
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#peek, Enumerator#peek_values... -
Hash
# transform _ values! -> Enumerator (12246.0) -
すべての値に対してブロックを呼び出した結果でハッシュの値を変更します。 キーは変化しません。
...nsform_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......_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!... -
Array
# fetch _ values(*indexes) -> Array (12245.0) -
引数で指定されたインデックスに対する値の配列を返します。
...//emlist[例][ruby]{
ary = ["a", "b", "c"]
ary.fetch_values(0, 2) # => ["a", "c"]
ary.fetch_values(-1, 1) # => ["d", "b"]
ary.fetch_values(0, 10) # => index 10 outside of array bounds: -3...3 (IndexError)
ary.fetch_values(0, 10) { |i| i.to_s } # => ["a", "10"]
//}
@see Array#values_at, Array#fet... -
Array
# fetch _ values(*indexes) { |index| . . . } -> Array (12245.0) -
引数で指定されたインデックスに対する値の配列を返します。
...//emlist[例][ruby]{
ary = ["a", "b", "c"]
ary.fetch_values(0, 2) # => ["a", "c"]
ary.fetch_values(-1, 1) # => ["d", "b"]
ary.fetch_values(0, 10) # => index 10 outside of array bounds: -3...3 (IndexError)
ary.fetch_values(0, 10) { |i| i.to_s } # => ["a", "10"]
//}
@see Array#values_at, Array#fet... -
MatchData
# values _ at(*index) -> [String] (12244.0) -
正規表現中の n 番目の括弧にマッチした部分文字列の配列を返します。
...チャの場合)で 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) # => ["foobarbaz", "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#[]...