80件ヒット
[1-80件を表示]
(0.045秒)
種類
- インスタンスメソッド (69)
- クラス (11)
モジュール
- Enumerable (24)
検索結果
先頭5件
-
Array
# map -> Enumerator (15122.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}
@see Hash#to_h, Enumerable#collect, Enumerable#map... -
Array
# map {|item| . . . } -> [object] (15122.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}
@see Hash#to_h, Enumerable#collect, Enumerable#map... -
Enumerable
# map -> Enumerator (15122.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map... -
Enumerable
# map {|item| . . . } -> [object] (15122.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map... -
Hash
# to _ h -> self | Hash (9214.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......s # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } #......=> {"A"=>65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ h {|key , value| block } -> Hash (9214.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
...す。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.clas......s # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } #......=> {"A"=>65, "B"=>66}
//}
@see Enumerable#map... -
Hash
# to _ proc -> Proc (9008.0) -
self のキーに対応する値を返す Proc オブジェクトを返します。
...self のキーに対応する値を返す Proc オブジェクトを返します。
//emlist[][ruby]{
h = {1 => 10, 2 => 20, 3 => 30}
[1, 2, 3].map(&h) # => [10, 20, 30]
//}... -
Enumerator
:: Lazy (90.0) -
map や select などのメソッドの遅延評価版を提供するためのクラス。
...map や select などのメソッドの遅延評価版を提供するためのクラス。
動作は通常の Enumerator と同じですが、以下のメソッドが遅延評価を行う
(つまり、配列ではなく Enumerator を返す) ように再定義されています。
* map/collect......* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk
* zip (※互換性のため、ブロックを渡さないケースのみlazy)
Lazyオブジェクトは、Enumerable#lazyメソッドによっ......zy#map は配列ではなく Enumerator を返すため、
# 巨大な配列を確保しようとしてメモリを使い切ったりはしない
open("log.txt"){|f|
f.each_line.lazy.map{|line|
Hash[line.split(/\t/).map{|s| s.split(/:/, 2)}]
}.select{|hash|
hash["req"] =~ /GET/ && hash["......* flat_map/collect_concat
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk
* zip (※互換性のため、ブロックを渡さないケースのみlazy)
Lazyオブジェクトは、Enumerable#lazyメソッドに......* flat_map/collect_concat
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk, chunk_while
* uniq
* zip (※互換性のため、ブロックを渡さないケースのみlazy)
Lazyオブジェクトは、Enumerabl......* flat_map/collect_concat
* filter_map
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk, chunk_while
* uniq
* zip (※互換性のため、ブロックを渡さないケースのみlazy)
Lazyオブジェクト......* flat_map/collect_concat
* filter_map
* select/find_all
* reject
* grep, grep_v
* take, take_while
* drop, drop_while
* slice_before, slice_after, slice_when
* chunk, chunk_while
* uniq
* compact
* zip (※互換性のため、ブロックを渡さないケースのみlazy)
Lazyオブ... -
Array
# collect -> Enumerator (22.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}
@see Hash#to_h, Enumerable#collect, Enumerable#map... -
Array
# collect {|item| . . . } -> [object] (22.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...してブロックを評価した結果を全て含む配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にする
p [1, 2, 3].map {|n| n * 3 } # => [3, 6, 9]
//}
@see Hash#to_h, Enumerable#collect, Enumerable#map... -
Enumerable
# collect -> Enumerator (22.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map... -
Enumerable
# collect {|item| . . . } -> [object] (22.0) -
各要素に対してブロックを評価した結果を全て含む配列を返します。
...配列を返します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
# すべて 3 倍にした配列を返す
p (1..3).map {|n| n * 3 } # => [3, 6, 9]
p (1..3).collect { "cat" } # => ["cat", "cat", "cat"]
//}
@see Hash#to_h, Array#collect, Array#map...