81件ヒット
[1-81件を表示]
(0.043秒)
種類
- インスタンスメソッド (77)
- 文書 (4)
ライブラリ
- ビルトイン (77)
クラス
- Array (22)
- Enumerator (11)
-
Enumerator
:: Lazy (11)
モジュール
- Enumerable (33)
キーワード
-
NEWS for Ruby 3
. 0 . 0 (4) - lazy (11)
- size (11)
検索結果
先頭5件
-
Enumerator
:: Lazy # drop _ while {|item| . . . } -> Enumerator :: Lazy (18366.0) -
Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
...Enumerable#drop_while と同じですが、配列ではなくEnumerator::Lazy を返します。
//emlist[例][ruby]{
1.step.lazy.drop_while { |i| i < 42 }
# => #<Enumerator::Lazy: #<Enumerator::Lazy: #<Enumerator: 1:step>>:drop_while>
1.step.lazy.drop_while { |i| i < 42 }.take(10).force
# => [42......, 43, 44, 45, 46, 47, 48, 49, 50, 51]
//}
@see Enumerable#drop_while... -
Array
# drop _ while {|element| . . . } -> Array (18321.0) -
ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。 このメソッドは自身を破壊的に変更しません。
...ロックを指定しなかった場合は、Enumerator を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
# 変数aの値は変化しない
a # => [1, 2, 3, 4, 5, 0]
//}
@see Enumerable#drop_while, Array#drop... -
Enumerable
# drop _ while {|element| . . . } -> Array (18315.0) -
ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。
...価して最初に偽となった要素の手前の要素まで捨て、
残りの要素を配列として返します。
ブロックを指定しなかった場合は、Enumerator を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
//}... -
Array
# drop _ while -> Enumerator (18221.0) -
ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。 このメソッドは自身を破壊的に変更しません。
...ロックを指定しなかった場合は、Enumerator を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
# 変数aの値は変化しない
a # => [1, 2, 3, 4, 5, 0]
//}
@see Enumerable#drop_while, Array#drop... -
Enumerable
# drop _ while -> Enumerator (18215.0) -
ブロックを評価して最初に偽となった要素の手前の要素まで捨て、 残りの要素を配列として返します。
...価して最初に偽となった要素の手前の要素まで捨て、
残りの要素を配列として返します。
ブロックを指定しなかった場合は、Enumerator を返します。
//emlist[例][ruby]{
a = [1, 2, 3, 4, 5, 0]
a.drop_while {|i| i < 3 } # => [3, 4, 5, 0]
//}... -
Enumerator
# size -> Integer | Float :: INFINITY | nil (308.0) -
self の要素数を返します。
...いた場合はその
実行結果を返します。呼び出した時に要素数が不明であった場合は nil を返し
ます。
//emlist[例][ruby]{
(1..100).to_a.permutation(4).size # => 94109400
loop.size # => Float::INFINITY
(1..100).drop_while.size # => nil
//}
@see Enumerator.new... -
NEWS for Ruby 3
. 0 . 0 (306.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...osplatting. This now matches the behavior of Procs
accepting a single rest argument and no keywords.
16166
//emlist[][ruby]{
pr = proc{|*a, **kw| [a, kw]}
pr.call([1])
# 2.7 => [[1], {}]
# 3.0 => [[[1]], {}]
pr.call([1, {a: 1}])
# 2.7 => [[1], {:a=>1}] # and deprecation warning
# 3.0 =>......mlist{
def method_missing(meth, ...)
send(:"do_#{meth}", ...)
end
//}
* Pattern matching (`case/in`) is no longer experimental. 17260
* One-line pattern matching is redesigned. [EXPERIMENTAL]
* `=>` is added. It can be used like a rightward assignment.
17260
* `in......-backtrace-limit` option limits the maximum length of a backtrace.
8661
== Core classes updates
Outstanding ones only.
* Array
* The following methods now return Array instances instead of subclass instances when called on subclass instances: 6087
* Array#drop
* Array#drop_while... -
Enumerable
# lazy -> Enumerator :: Lazy (136.0) -
自身を lazy な Enumerator に変換したものを返します。
...うに再定義されています。
* map/collect
* flat_map/collect_concat
* select/find_all
* reject
* grep
* take, take_while
* drop, drop_while
* zip (※一貫性のため、ブロックを渡さないケースのみlazy)
* cycle (※一貫性のため、ブロックを渡さない......ラムです。
//emlist[例][ruby]{
def pythagorean_triples
(1..Float::INFINITY).lazy.flat_map {|z|
(1..z).flat_map {|x|
(x..z).select {|y|
x**2 + y**2 == z**2
}.map {|y|
[x, y, z]
}
}
}
end
# 最初の10個のピタゴラス数を表示する
p pythag......orean_triples.take(10).force # takeはlazyなので、forceが必要です
p pythagorean_triples.first(10) # firstはeagerです
# 100より小さいピタゴラス数を表示する
p pythagorean_triples.take_while { |*, z| z < 100 }.force
//}
@see Enumerator::Lazy...