Pere Casafont
02/26/2018, 3:06 AMRuckus
02/26/2018, 3:42 AMbenleggiero
02/26/2018, 4:50 AMlet
, its members cannot be changed. This is a huge strength of value types. Additionally, if it’s a var
, then any mutation creates a new object in memory, so the original’s is not mutated. This copy-on-write creates so much peace-of-mind that I feel safe doing pretty much anything to any struct
at any time. They’re inherently thread-safe and inherently immune to concurrency side-effects. They still require a gentle touch if you want to ensure just one value comes out of a concurrent operation, but at least you will know that whatever comes out wasn’t stepped on by many threads.
Can’t wait for Kotlin value types. Hope they’re as useful as Swift’s!snrostov
02/26/2018, 6:56 AMSadly, it’s a limitation of both JVM and JSJS supports freeze on object and arrays
Object.freeze(arr);
Object.isFrozen(arr);
Pere Casafont
02/26/2018, 9:06 AMcypher121
02/27/2018, 2:51 PMPere Casafont
02/27/2018, 2:54 PMThing?
to java and it will be able to do thing.whatever
without any issuesPere Casafont
02/27/2018, 2:54 PMsnrostov
02/27/2018, 2:56 PMyou can send aKotlin compiler insert null-checkes on every public method. The same should be for mutable methods of immutable objects.to java and it will be able to doThing?
without any issuesthing.whatever
Pere Casafont
02/27/2018, 3:01 PMbenleggiero
03/02/2018, 12:15 AMcodejanovic
03/02/2018, 7:59 AMcodejanovic
03/02/2018, 8:01 AMPere Casafont
03/02/2018, 8:17 AMcodejanovic
03/02/2018, 8:49 AMPere Casafont
03/02/2018, 8:58 AMcodejanovic
03/02/2018, 12:16 PM