種類
- インスタンスメソッド (1662)
- 特異メソッド (211)
- モジュール関数 (44)
- クラス (33)
- モジュール (11)
クラス
-
ARGF
. class (238) - Array (154)
- Dir (106)
- Enumerator (167)
-
Enumerator
:: ArithmeticSequence (12) -
Enumerator
:: Chain (12) -
Enumerator
:: Lazy (167) -
Enumerator
:: Yielder (27) - Hash (144)
- IO (304)
- Object (44)
- Range (22)
- StopIteration (11)
- String (102)
- Struct (44)
モジュール
- Enumerable (231)
- ObjectSpace (44)
オブジェクト
- ENV (88)
キーワード
- + (6)
- << (11)
- Enumerable (11)
- Enumerator (11)
- Fiber (11)
- Lazy (11)
- bytes (28)
- chars (28)
- chunk (33)
-
chunk
_ while (11) - codepoints (28)
- collect! (22)
-
collect
_ concat (11) -
delete
_ if (22) -
each
_ byte (66) -
each
_ char (66) -
each
_ child (40) -
each
_ codepoint (66) -
each
_ cons (22) -
each
_ entry (22) -
each
_ grapheme _ cluster (14) -
each
_ index (22) -
each
_ key (44) -
each
_ line (132) -
each
_ object (44) -
each
_ pair (66) -
each
_ slice (22) -
each
_ value (44) -
each
_ with _ index (22) -
each
_ with _ object (22) - eager (5)
-
enum
_ for (44) - feed (11)
- filter! (12)
-
flat
_ map (11) - foreach (66)
-
keep
_ if (22) - lines (84)
- map! (22)
- new (29)
- next (11)
-
next
_ values (11) -
peek
_ values (11) - reject! (22)
- result (11)
-
reverse
_ each (44) - rewind (11)
- select! (22)
-
slice
_ after (42) -
slice
_ before (55) -
slice
_ when (21) -
take
_ while (22) -
to
_ enum (44) -
to
_ proc (5) -
with
_ index (22) -
with
_ object (22) - yield (11)
検索結果
先頭5件
-
Array
# map! {|item| . . } -> self (22.0) -
各要素を順番にブロックに渡して評価し、その結果で要素を 置き換えます。
...なかった場合は、自身と map! から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
ary = [1, 2, 3]
ary.map! {|i| i * 3 }
p ary #=> [3, 6, 9]
ary = [1, 2, 3]
e = ary.map!
e.each{ 1 }
p ary #=> [1, 1, 1]
//}
@see Array#collect, Enumerator... -
Hash
# keep _ if {|key , value| . . . } -> self (22.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
...れなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:sele... -
Hash
# select! {|key , value| . . . } -> self | nil (22.0) -
キーと値を引数としてブロックを評価した結果が真であるような要素を self に残します。
...れなかった場合は、自身と keep_if から生成した
Enumerator オブジェクトを返します。
//emlist[例][ruby]{
h1 = {}
c = ("a".."g")
c.each_with_index {|e, i| h1[i] = e }
h2 = h1.dup
h1.select! # => #<Enumerator: {0=>"a", 1=>"b", 2=>"c", 3=>"d", 4=>"e", 5=>"f", 6=>"g"}:sele... -
ARGF
. class # bytes { |byte| . . . } -> self (19.0) -
このメソッドは obsolete です。 代わりに ARGF.class#each_byte を使用してください。 使用すると警告メッセージが表示されます。
...このメソッドは obsolete です。
代わりに ARGF.class#each_byte を使用してください。
使用すると警告メッセージが表示されます。... -
ARGF
. class # chars { |c| . . . } -> self (19.0) -
このメソッドは obsolete です。 代わりに ARGF.class#each_char を使用してください。 使用すると警告メッセージが表示されます。
...このメソッドは obsolete です。
代わりに ARGF.class#each_char を使用してください。
使用すると警告メッセージが表示されます。... -
ARGF
. class # codepoints { |c| . . . } -> self (19.0) -
このメソッドは obsolete です。 代わりに ARGF.class#each_codepoint を使用してください。 使用すると警告メッセージが表示されます。
...このメソッドは obsolete です。
代わりに ARGF.class#each_codepoint を使用してください。
使用すると警告メッセージが表示されます。... -
Enumerable
# take _ while {|element| . . . } -> Array (15.0) -
Enumerable オブジェクトの要素を順に偽になるまでブロックで評価します。 最初に偽になった要素の手前の要素までを配列として返します。
...クで評価します。
最初に偽になった要素の手前の要素までを配列として返します。
//emlist[例][ruby]{
e = [1, 2, 3, 4, 5, 0].each
e.take_while {|i| i < 3 } # => [1, 2]
//}
ブロックを省略した場合は Enumerator を返します。
@see Array#take_while... -
Fiber (14.0)
-
ノンプリエンプティブな軽量スレッド(以下ファイバーと呼ぶ)を提供します。 他の言語では coroutine あるいは semicoroutine と呼ばれることもあります。 Thread と違いユーザレベルスレッドとして実装されています。
...は内部イテレータを外部イテレータに変換する例です。
実際 Enumerator は Fiber を用いて実装されています。
//emlist[例:][ruby]{
def enum2gen(enum)
Fiber.new do
enum.each{|i|
Fiber.yield(i)
}
end
end
g = enum2gen(1..100)
p g.resume #=> 1
p...