victor-mntl
11/23/2019, 1:13 PMenum class Foo1 (val bar:Int) {FIRST(11), SECOND(222)}barprintln(Foo1.FIRST.bar)11valenum class Foo2 (bar:Int) {FIRST(110), SECOND(2220)}barprintln(Foo2.FIRST.bar)error: unresolved reference: bar1102220Xavier F. Gouchet
11/23/2019, 1:33 PMinitvictor-mntl
11/23/2019, 1:42 PMFoo3Foo2enum class Foo3 (bar:Int) {FIRST(_bar:_ 110), SECOND(_bar:_ 2220);;val bar2:Int = bar + 2 }println(Foo3.FIRST.bar)error: unresolved reference: barprintln(Foo3.FIRST.bar2)112victor-mntl
11/23/2019, 1:46 PMFoo4Foo3initenum class Foo3 (bar:Int) {FIRST(_bar:_ 110), SECOND(_bar:_ 2220);init{val bar2:Int = bar + 2} }println(Foo3.FIRST.bar)error: unresolved reference: barprintln(Foo3.FIRST.bar2)error: unresolved reference: bar2victor-mntl
11/23/2019, 1:47 PMinitenum classAlowaniak
11/23/2019, 2:13 PMvalobjectvictor-mntl
11/23/2019, 2:31 PMFoo()victor-mntl
11/23/2019, 2:43 PMinit{...}init{...}victor-mntl
11/23/2019, 3:03 PMenum class Foo () {FIRST, SECOND, THIRD;init {println("init called for ${this.name} instance")}}fun main() {println("Testing to assign SECOND:")val test2:Foo = Foo.SECONDprintln("Testing to assign FIRST:")val test1:Foo = Foo.FIRSTprintln("Testing to assign THIRD:")val test3:Foo = Foo.THIRDprintln("Testing to assign FIRST again:")val test4:Foo = Foo.FIRST}Testing to assign SECOND:
init called for FIRST instance
init called for SECOND instance
init called for THIRD instance ***
Testing to assign FIRST:
Testing to assign THIRD:
Testing to assign FIRST again: