mbonnin
03/24/2021, 4:37 PMfoo.bar()
2. foo.asBar()
3. foo.toBar()
4. foo.withBar()
I'd tend to use mostly 1. with maybe 4. when it returns the same type as the receiver but I'm curious if there are established guidelines when to use what?ephemient
03/24/2021, 4:54 PM.asBar()
, new = .toBar()
val a = arrayOf(1, 2, 3)
val b = a.asList()
val c = b.toList()
a[2] = 4
b == listOf(1, 2, 4)
c == listOf(1, 2, 3)
mbonnin
03/24/2021, 5:05 PM.asBar()
muchlouiscad
04/03/2021, 10:49 AMtoBar()
one can still wrap instead of doing a copy.ephemient
04/03/2021, 5:20 PM