TwoClocks
08/29/2020, 11:01 PMfun time() = internalTime vs val time = internalTime ?brandonmcansh
08/30/2020, 12:22 AMval time = internalTime is immutable and would return the same value on each query whereas fun time() would (assuming it's not a constant).
val time: Long
get() = internalTime
Would be equivalent fun time()TwoClocks
08/30/2020, 12:24 AMTwoClocks
08/30/2020, 12:26 AMbrandonmcansh
08/30/2020, 12:26 AMbrandonmcansh
08/30/2020, 12:26 AMbrandonmcansh
08/30/2020, 12:26 AMval time = internalTime is immutable and update on each query whereas fun time() would (assuming it's not a constant).
val time: Long
get() = internalTime
Is returning internalTime each time time is calledTwoClocks
08/30/2020, 12:28 AMfun time() = internalTime ? Or is it syntactic sugar for the same thing?brandonmcansh
08/30/2020, 12:28 AMbrandonmcansh
08/30/2020, 12:29 AMbrandonmcansh
08/30/2020, 12:31 AMTwoClocks
08/30/2020, 12:31 AMget() some compiler magic? It doesn't look like a type, which is what you would expect there.brandonmcansh
08/30/2020, 12:31 AMTwoClocks
08/30/2020, 12:36 AMget()?brandonmcansh
08/30/2020, 12:36 AMbrandonmcansh
08/30/2020, 12:37 AMval time: Long
get {
return internalTime
}TwoClocks
08/30/2020, 12:45 AMpublic var time:Long=0
private set
I don't even need internalTime any more. neato!
Thanks man! learned something new about kotlin todaybrandonmcansh
08/30/2020, 12:45 AMTwoClocks
08/30/2020, 12:47 AMbrandonmcansh
08/30/2020, 12:51 AMprivate void setTime(long time) {}
public long getTime()brandonmcansh
08/30/2020, 12:52 AMNir
08/30/2020, 12:56 AMNir
08/30/2020, 12:57 AMvalbrandonmcansh
08/30/2020, 12:57 AMTwoClocks
08/30/2020, 12:58 AMNir
08/30/2020, 12:58 AMTwoClocks
08/30/2020, 12:59 AMNir
08/30/2020, 12:59 AMbrandonmcansh
08/30/2020, 12:59 AMNir
08/30/2020, 12:59 AMdata class foo(val bar: List<Int>)
val x = mutableListOf(1)
val f = foo(x)
x.add(2)TwoClocks
08/30/2020, 1:00 AMset is private get "erased" etc?Nir
08/30/2020, 1:00 AMval and it's List, not MutableListNir
08/30/2020, 1:00 AMNir
08/30/2020, 1:01 AMMutableList, or a dataclass with at least one var field then it's even easierbrandonmcansh
08/30/2020, 1:02 AMbrandonmcansh
08/30/2020, 1:02 AMTwoClocks
08/30/2020, 1:02 AMTwoClocks
08/30/2020, 1:03 AMTwoClocks
08/30/2020, 1:05 AMNir
08/30/2020, 1:19 AMNir
08/30/2020, 1:19 AMbrandonmcansh
08/30/2020, 1:21 AMbrandonmcansh
08/30/2020, 1:21 AMNir
08/30/2020, 1:21 AMNir
08/30/2020, 1:21 AMbrandonmcansh
08/30/2020, 1:22 AMNir
08/30/2020, 1:23 AMNir
08/30/2020, 1:23 AMNir
08/30/2020, 1:29 AMNir
08/30/2020, 1:29 AMNir
08/30/2020, 1:29 AMNir
08/30/2020, 1:29 AMval Int is really immutableTwoClocks
08/30/2020, 1:31 AMpublic var time:Long=0
private set
can time be modified externally to the class/object that declares it? (I'm not saying anything about the mutability of time here)Nir
08/30/2020, 1:34 AMTwoClocks
08/30/2020, 1:35 AMNir
08/30/2020, 1:38 AMNir
08/30/2020, 1:38 AMNir
08/30/2020, 1:38 AMNir
08/30/2020, 1:38 AMTwoClocks
08/30/2020, 2:34 AMNir
08/30/2020, 2:39 AM