python (65.2k questions)
javascript (44.3k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (13k questions)
Kotlin. How to declare constant?
I have class, which in primary constructor has some fields:
class SomeData(val counter: Int...) { // some logic}
I need to create a constant. I usually do it like this:
companion object {
priva...
testivanivan
Votes: 0
Answers: 3
In Kotlin, Why can the value of a val integer be reassigned by the inc() method?
Consider the following,
val x: Int = 0
val variables cannot be changed so doing x += 1 wouldn't work
The compiler says Val cannot be reassigned
why then does x.inc() work fine
doesn't x.inc() reassign...
Ser.T
Votes: 0
Answers: 1