damian
03/15/2017, 5:43 PMnkiesel
03/15/2017, 6:52 PMclass
, sealed class
and open class
to a co-worker he asked: why is sealed
not the default, given that developer has control on what goes into the same file anyway (i.e. why is class
not the same as sealed class
)? I did not have a good answer. can anyone help me out?jackmiras
03/16/2017, 2:04 AMcedric
03/16/2017, 6:30 AMthijs
03/16/2017, 9:41 AMrobin
03/16/2017, 12:54 PMd.toString().trim('0')
would be one waydanko9
03/16/2017, 1:38 PMilya.gorbunov
03/16/2017, 1:44 PMuser
03/16/2017, 3:35 PMeygraber
03/16/2017, 4:50 PMfun <T: Any?> T?.or(other: T): T {
return if(this == null) {
other
}
else {
this
}
}
bitkid
03/16/2017, 5:08 PMkoral
03/17/2017, 1:25 AMoverride fun processNewLines(lines: Array<String>) = lines.forEach { <http://logger.info|logger.info>(it) }
and it works as expected however when I change last invocation to lambda: override fun processNewLines(lines: Array<String>) = lines.forEach { logger::info }
code compiles fine but there is a runtime error java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReference.<init>(ILjava/lang/Object;)V
at that linenulldev
03/17/2017, 3:04 AMtoByte()
on -128
results in 128
?
Java bytes can only hold -128
to 127
anyways!
Example code:
fun main(args: Array<String>) {
println(-128.toByte())
println(-127.toByte())
}
Result:
128
-127
Casting -128
to byte
in Java returns -128
as expected.mg6maciej
03/17/2017, 8:37 AMinline fun <reified T : Any> myFunc() = myFuncImpl(T::class)
internal fun <T : Any> myFuncImpl(clazz: KClass<T>) {}
#language-proposals How about making this compile?pavlospt
03/17/2017, 2:31 PMoverride fun <T> getFoo() : T? { return fromBytes(byteArray) }
udalov
03/17/2017, 7:55 PMorangy
03/18/2017, 1:37 AMdavid.bilik
03/18/2017, 7:00 PMError:(5, 0) For input string: ""
Open File
Nothing changes and the line in build.gradle is apply plugin: ‘kotlin-android’
. The stacktrace of error says Failed to notify ProjectEvaluationListener.afterEvaluate(), but primary configuration failure takes precedence.
java.lang.IllegalStateException: buildToolsVersion is not specified.
Of course my build tools version is set
If i build my project with —stacktrace option, this is what is printed in console Caused by: java.lang.NumberFormatException: For input string: ""
at org.jetbrains.kotlin.incremental.CacheVersion.getActualVersion(
at org.jetbrains.kotlin.incremental.CacheVersion.checkVersion(
at org.jetbrains.kotlin.incremental.BuildCacheStorage.<init>(
at org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices.<init>(
at org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices.<init>(
at org.jetbrains.kotlin.gradle.plugin.KotlinGradleBuildServices$Companion
at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(
at org.jetbrains.kotlin.gradle.plugin.KotlinBasePluginWrapper.apply(
at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.
at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(
... 72 more
johnl
03/18/2017, 10:12 PMtschuchort
03/20/2017, 1:06 PM_
as a parameter name in normal functions?zak.taccardi
03/20/2017, 7:27 PMgroostav
03/20/2017, 9:21 PMmp
03/20/2017, 9:30 PMlinear
03/20/2017, 10:29 PMrwachol
03/21/2017, 10:14 AMvach
03/21/2017, 11:09 AMghosalmartin
03/21/2017, 4:09 PMlinear
03/21/2017, 9:00 PMean5533
03/22/2017, 3:17 PMsvenjacobs
03/23/2017, 7:32 AMClass
or a Kotlin KClass
is expected. ::class.java
will return Class
.svenjacobs
03/23/2017, 7:32 AMClass
or a Kotlin KClass
is expected. ::class.java
will return Class
.moelholm
03/23/2017, 7:55 AMokkero
03/23/2017, 8:08 AMKClass
does not in general share an is-a relationship with Class
See quote:
"If you need to specify a class as an argument of an annotation, use a Kotlin class (KClass). The Kotlin compiler will automatically convert it to a Java class, so that the Java code will be able to see the annotations and arguments normally."
https://kotlinlang.org/docs/reference/annotations.html#constructorsmoelholm
03/23/2017, 8:14 AM