neworldlt
04/05/2016, 7:07 AMlazyVar
in kotlin? I have synchronized implementation here: https://gist.github.com/neworld/843d99e7f7a783713b5593bba888249a
tl;tr; lazyVar
should fulfill these tests:
var fixture: Int by lazyVar { 1 }
@Test
fun testLazyInitialization() {
assertEquals(1, fixture)
}
@Test
fun testOverrideInitializedVariable() {
assertEquals(1, fixture)
fixture = 2
assertEquals(2, fixture)
}
@Test
fun testSetVariableBeforeInitialization() {
fixture = 2
assertEquals(2, fixture)
}