We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 945985a commit 7ff924aCopy full SHA for 7ff924a
core-kotlin-modules/core-kotlin-10/src/main/kotlin/com/baeldung/assignwhile/AssignWhileSamples.kt
@@ -0,0 +1,30 @@
1
+package com.baeldung.assignwhile
2
+
3
+fun simpleVarAssignmentOutsideLoop() {
4
+ val sentinelValue = 10
5
+ var value: Int = 0
6
+ while (value != sentinelValue) {
7
+ // do something...
8
+ value++
9
+ }
10
+}
11
12
+fun whileWithBreakStatement() {
13
14
+ while (true) {
15
+ val value = getValue()
16
+ if (value == sentinelValue) break
17
+ // Process value
18
19
20
21
+fun usingDoWhile() {
22
23
+ do {
24
25
26
27
+ } while (true)
28
29
30
+private fun getValue() = 10
0 commit comments