Roman Elizarov | 5b5dc17 | 2017-03-13 15:02:30 +0300 | [diff] [blame] | 1 | /* |
Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Roman Elizarov | 5b5dc17 | 2017-03-13 15:02:30 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | package kotlinx.coroutines.experimental.selects |
| 6 | |
| 7 | /** |
| 8 | * Loops while [select] expression returns `true`. |
| 9 | * |
| 10 | * The statement of the form: |
| 11 | * |
| 12 | * ``` |
| 13 | * whileSelect { |
| 14 | * /*body*/ |
| 15 | * } |
| 16 | * ``` |
| 17 | * |
| 18 | * is a shortcut for: |
| 19 | * |
| 20 | * ``` |
| 21 | * while(select<Boolean> { |
| 22 | * /*body*/ |
| 23 | * }) {} |
| 24 | */ |
| 25 | suspend fun whileSelect(builder: SelectBuilder<Boolean>.() -> Unit) { |
| 26 | while(select<Boolean>(builder)) {} |
| 27 | } |