+ 1

Kotlin functions - how do I feature a variable in a function that is also used elsewhere in the programme?

For example, if I had two functions, and the same variable was needed in both, where would I initialise it, and how would I make sure both functions could access the variable?

2nd Oct 2020, 6:47 PM
Phillipa Austin-Seymour
Phillipa Austin-Seymour - avatar
4 odpowiedzi
+ 2
Ohh, take this as example class PAS { lateinit var to:Int fun foobar(){ to = 7 } fun toobat(){ to = 89 } }
2nd Oct 2020, 6:52 PM
Ananiya Jemberu
Ananiya Jemberu - avatar
+ 1
Thank you so much guys.
3rd Oct 2020, 3:58 PM
Phillipa Austin-Seymour
Phillipa Austin-Seymour - avatar
+ 1
Ok
3rd Oct 2020, 3:58 PM
Ananiya Jemberu
Ananiya Jemberu - avatar