We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 70be2df + 072b2e5 commit 84099a7Copy full SHA for 84099a7
tests/pos/i18345.scala
@@ -0,0 +1,28 @@
1
+extension (vec: Seq[Int])
2
+ def iterate[T](body: (() => Int) => T): T =
3
+ val iterator = vec.iterator
4
+ body(() => iterator.nextOption().getOrElse(0))
5
+
6
+def withSequence[T](n: Int)(body: Seq[Int] => T): T =
7
+ body((0 to n))
8
9
+def test =
10
11
+ withSequence(2):
12
+ _.iterate: next =>
13
+ next() + next() + next() + next()
14
15
16
+ _.iterate:
17
+ next =>
18
19
20
+ withSequence(2): x =>
21
+ x.iterate:
22
23
24
25
26
+ x.iterate: next =>
27
28
0 commit comments