4 ms·
lazy init in kotlin and scala is essentially the same thing. the good thing with go's sync.Once is that it's implemented as a library instead of something in t
by fishywang 6y ago
lazy init in kotlin and scala is essentially the same thing.
the good thing with go's sync.Once is that it's implemented as a library instead of something in the language itself, so it's easy for curious user to see how it's actually implemented. they even have comments there pointing out wrong implementations, which I have seen people make the exact same mistake during code reviews (in other language).