bod
02/14/2019, 12:44 PMenum class MyEnum(val key: String) {
FOO("foo"),
BAR("bar"),
UNKNOWN("unknown");
companion object {
fun getByKey(key: String?): MyEnum {
return MyEnum.values().firstOrNull { it.key == key } ?: MyEnum.UNKNOWN
}
}
}
I’m looking for a way to not repeat this companion object for all our enums. Possibly a combination of an interface and a generic extension function? Any idea? 🙂
[sorry I already posted this before to an unrelated channel by mistake]thana
02/14/2019, 1:10 PM./gradlew build
i now always get this error
> Task :authmock:compileKotlin FAILED
e: No class roots are found in the JDK path: /usr/lib/jvm/java-12-openjdk-amd64
any idea what to do?Marcin Wisniowski
02/14/2019, 3:19 PMjava.lang.Long.parseLong()
Why isn't this available in the Kotlin Long
?LeoColman
02/14/2019, 3:34 PMLeoColman
02/14/2019, 3:34 PMEnum.foo
would sometimes be differente from Enum.foo
, and that's impossible?elect
02/14/2019, 5:46 PMDaveQ
02/14/2019, 5:53 PMScott Dillender
02/14/2019, 6:17 PMsequence {
yield(channelSubscription.receive())
}
but that errors out with: Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope
james.ayvaz
02/14/2019, 7:55 PMjeremy
02/15/2019, 4:12 AMserebit
02/15/2019, 4:13 AMsitepodmatt
02/15/2019, 4:22 AMelect
02/15/2019, 9:19 AMval values: Array<out Enum<*>> = Enum::class.java.enumConstants
aerialist
02/15/2019, 11:56 AMegorand
02/15/2019, 3:55 PMenum class RenderPassCreate(override val value: Int) {
companion object
}
This is the code we currently generate, and it will not compile, with the error being Expecting ';' after the last enum entry or '}' to close enum class body
. The compiler expects the following:
enum class RenderPassCreate(override val value: Int) {
;
companion object
}
which in my opinion looks ugly. I wonder if there’s a hard technical limitation behind this, and whether the compiler could handle this better? Tried searching YouTrack and it doesn’t look like it’s been filedstreetsofboston
02/15/2019, 5:56 PMif
, when
, try
expressions in Kotlin, but not in Java).
What was the reason that the assignment operator =
is not an expression?Dominaezzz
02/15/2019, 7:04 PMSeri
02/15/2019, 8:18 PMlist.filter { ... }.isNotEmpty()
? IDEA is telling me that the calls could be simplified, but I’m not seeing howJames
02/15/2019, 9:17 PMbasher
02/16/2019, 12:59 AMelect
02/16/2019, 7:30 AMclass Whatever // Java
// kotlin
fun Whatever.String.extend() = 3
fun a(block: Whatever.()->Unit) {
Whatever().block()
}
// in order to do somewhere in code
a {
"hello".extend()
}
GarouDan
02/16/2019, 1:30 PMDockerfile
?GarouDan
02/16/2019, 4:26 PM> Task :common:linkTestDebugExecutableNativeAndroidArm32 FAILED
/root/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/llvm-lto: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory
error: compilation failed: The /root/.konan/dependencies/clang-llvm-6.0.1-linux-x86-64/bin/llvm-lto command returned non-zero exit code: 127.
Does someone knows how to fix this? The library libtinfo.so.5
is missing.
It looks like this could be related with ncurses
. Some people suggested to install this package yum install ncurses-compat-libs
but I don’t know which package I should install when using debian.amanda.hinchman-dominguez
02/17/2019, 12:46 AMamanda.hinchman-dominguez
02/17/2019, 1:11 AMModule... modules
mean you can pass in a vararg in to the function call?amanda.hinchman-dominguez
02/17/2019, 1:16 AMamanda.hinchman-dominguez
02/17/2019, 1:20 AMRohan Maity
02/17/2019, 9:18 AMcamdenorrb
02/17/2019, 12:14 PMfrellan
02/17/2019, 9:52 PMFoo
is a Stream<Whatever>
, I want to map and convert it to a Sequence, is there any difference at all between these?
foo
.asSequence()
.map { it.doStuff() }
or
foo
.map { it.doStuff() }
.asSequence()