有两种选择:
1)如果要中断值序列:
source.repeat(n).takeWhile(condition);
source.repeat(n).takeUntil(condition);
Run Code Online (Sandbox Code Playgroud)
2)如果要重复n次或直到不再满足条件:
source.repeatWhen(o -> o.scan(1, (a, b) -> a + 1).takeUntil(i -> i < n || condition)))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2937 次 |
| 最近记录: |