Jay
02/10/2019, 3:00 PMJay
02/10/2019, 3:06 PMPHondogo
02/11/2019, 8:12 AMreik.schatz
02/11/2019, 1:00 PMHullaballoonatic
03/09/2019, 2:11 AMjacob
03/09/2019, 2:12 AMHullaballoonatic
03/09/2019, 2:13 AMHullaballoonatic
03/09/2019, 2:28 AMit
for anonymous functionssitepodmatt
03/09/2019, 2:42 AMHullaballoonatic
03/09/2019, 2:43 AMLeoColman
03/09/2019, 4:09 AMLeoColman
03/09/2019, 4:10 AMArshak Ulubabyan
03/09/2019, 11:28 PMiex
03/10/2019, 3:38 PMfun myMethod(): String? {
val foo = myOptional ?: return null
}
iex
03/10/2019, 3:39 PMfun myMethod(): String? {
val foo = myOptional ?: {
println("myOptional is null")
return null
}
}
karelpeeters
03/10/2019, 3:40 PM?: run { ... }
iex
03/10/2019, 3:40 PMsitepodmatt
03/10/2019, 3:40 PMkarelpeeters
03/10/2019, 3:40 PMreturn null
in it, sure.iex
03/10/2019, 3:41 PMiex
03/10/2019, 3:41 PMsitepodmatt
03/10/2019, 3:43 PMkarelpeeters
03/10/2019, 3:46 PMsitepodmatt
03/10/2019, 3:46 PMval foo = myOptional ?: return null.also { println("it is null") }
iex
03/10/2019, 3:47 PMGarouDan
03/10/2019, 7:14 PMprintln(MyClass.myMapKey1)
println(MyClass.myMapKey2)
...
println(MyClass.myMapKeyN)
Maybe somehow a way to eval a code? Or another technique? (I would like to use this with kotlin-dsl.)
My motivation is that I would like to retrieve a map from a properties file (a yaml one), but if possible, I would like to access my keys like if I was using an enum.
Since the nature of this properties could be dynamic and they could change, it’s not a good idea to use a enum or a class with a defined companion object.
We could access this keys as usual myMap["myMapKey1"], ..., myMap["myMapKeyN"]
but I would like to avoid typos and use it like an enum, improving the experience with autocompletion.
Can we achieve something like that?LeoColman
03/11/2019, 2:23 AMLeoColman
03/11/2019, 2:25 AMsitepodmatt
03/11/2019, 2:43 AMsitepodmatt
03/11/2019, 2:43 AM