Florian
10/04/2019, 2:44 PMval a
get() = Random().nextInt(10)
Is this the only situation a val
can return a different value each time it is accessed? (obviously the Random function is replaceable)alex
10/04/2019, 3:05 PMget()
is a syntax sugar for something like:
class A {
String getA() { return new Random().nextInt(10); }
}
Florian
10/04/2019, 3:14 PMThomas
10/04/2019, 7:08 PMkarelpeeters
10/04/2019, 11:17 PMval
implementors can provide whatever getter they want. Still the same, but something to look out for.