360件ヒット
[301-360件を表示]
(0.115秒)
ライブラリ
- ビルトイン (360)
クラス
-
Enumerator
:: ArithmeticSequence (21) -
Enumerator
:: Lazy (201) - Numeric (93)
- Range (45)
キーワード
- % (14)
- == (7)
- chunk (24)
- collect (12)
- force (12)
- hash (7)
- map (12)
- reject (12)
- select (12)
-
slice
_ after (22) -
slice
_ before (36) -
slice
_ when (11) -
take
_ while (24) - zip (24)
検索結果
先頭5件
-
Range
# %(s) -> Enumerator :: ArithmeticSequence (140.0) -
範囲内の要素を s おきに繰り返します。
...::ArithmeticSequence を返します。
@return ブロックを指定しなかったその他の Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"... -
Range
# %(s) -> Enumerator (58.0) -
範囲内の要素を s おきに繰り返します。
...::ArithmeticSequence を返します。
@return ブロックを指定しなかったその他の Range の時は Enumerator を返します。(例: String の Range)
//emlist[例][ruby]{
(1..10).step(3) {|v| p v}
# => 1
# 4
# 7
# 10
("a".."f").step(2) {|v| p v}
# => "a"
# "c"
# "e"......e は each でイテレートできない
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).each { |t| p t }
# => 'Range#each': can't iterate from Time (TypeError)
# step は使用可能
(Time.utc(2024, 12, 25)...Time.utc(2024, 12, 26)).step(60*60*6) { |t| p t }
# => 2024-12-25 00:00:00 UTC
# 20......24-12-25 06:00:00 UTC
# 2024-12-25 12:00:00 UTC
# 2024-12-25 18:00:00 UTC
("a"..).step("*").take(3) # => ["a", "a*", "a**"]
//}... -
Enumerator
:: Lazy # take _ while -> Enumerator :: Lazy (25.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...[ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }.force.last(5)......# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}
@see Enumerable#take_while... -
Enumerator
:: Lazy # take _ while {|item| . . . } -> Enumerator :: Lazy (25.0) -
Enumerable#take_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...[ruby]{
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>:take_while>
1.step.lazy.zip(('a'..'z').cycle).take_while { |e| e.first < 100_000 }.force.last(5)......# => [[99995, "y"], [99996, "z"], [99997, "a"], [99998, "b"], [99999, "c"]]
//}
@see Enumerable#take_while... -
Enumerator
:: Lazy # zip(*lists) -> Enumerator :: Lazy (25.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
...//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}
@see... -
Enumerator
:: Lazy # zip(*lists) {|v1 , v2 , . . . | . . . } -> nil (25.0) -
Enumerable#zip と同じですが、配列ではなくEnumerator::Lazy を返します。
...//emlist[例][ruby]{
1.step.lazy.zip(('a'..'z').cycle)
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:zip(#<Enumerator: "a".."z":cycle>)>
1.step.lazy.zip(('a'..'z').cycle).take(30).force.last(6)
# => [[25, "y"], [26, "z"], [27, "a"], [28, "b"], [29, "c"], [30, "d"]]
//}
@see...