Changed the task a bit to avoid having 'redundant initializer' IJ inspection
based on https://github.com/BruceEckel/AtomicKotlinExamples/issues/15
This commit is contained in:
parent
09aa533a41
commit
2573f12d1e
|
@ -3,6 +3,7 @@ package varAndValExercise1
|
|||
|
||||
fun main() {
|
||||
var answer = 42
|
||||
println(answer)
|
||||
answer = 43
|
||||
println(answer)
|
||||
}
|
|
@ -4,7 +4,7 @@ files:
|
|||
visible: true
|
||||
placeholders:
|
||||
- offset: 65
|
||||
length: 47
|
||||
length: 65
|
||||
placeholder_text: // TODO
|
||||
- name: test/output.txt
|
||||
visible: false
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
## `var` & `val` (#1)
|
||||
|
||||
Define a `val answer` and set its value to `42`. On the next line, try to
|
||||
reassign `answer` to `43`. What error does Kotlin produce? Fix the error by
|
||||
replacing `val` with `var`. Display the value of `answer` on the console.
|
||||
Define a `val answer` and set its value to `42`.
|
||||
Display the value of `answer` on the console.
|
||||
|
||||
On the next line, try to reassign `answer` to `43`.
|
||||
What error does Kotlin produce? Fix the error by replacing `val` with `var`.
|
||||
Display the new value of `answer` on the console.
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
42
|
||||
43
|
||||
|
|
Loading…
Reference in New Issue