ursus
07/15/2019, 12:58 AMSudhir Singh Khanger
07/15/2019, 4:10 AMif (nullableIntOne ?: 0 < nullableList?.size ?: 0) {
// some code 1
} else {
// some code 2
}
I can't compare nullable types. So what is the likelihood of above code breaking. How can I mitigate it?rdgoite
07/15/2019, 2:32 PMget()
is called. However, I just found out that defining something like,
var myCollection: MutableList<String> = mutableListOf()
private set
get() = field.toMutableList()
is problematic because calling this.myCollection
within the class itself seem to call the getter instead. My current alternative is to make it immutable collection and replace it every time there are changes. However, that seems to be a little more work than it should be. Any ideas?Nikolai
07/15/2019, 4:34 PMbuildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
Why we need repositories here? According to docs it configure repositories for current project. But this is the root file. And it have repositories inside buildscript. This repositories didn't count for subprojects (whats why child build.script have it's own repositories closure). If I remove it - nothing changes, app still build and run (at least on Android). In Android studio this closure looks like :
allprojects {
repositories {
google()
jcenter()
}
}
Which is quite understandable. Maybe I am missing something and this repository closure have some purpose?Katie Levy
07/15/2019, 4:43 PMnwh
07/15/2019, 7:29 PMOptional
? Where there are three valid values: regular value, null, nothing. I'm using a data class so a lateinit var
isn't exactly the best solutionStefan Peterson
07/15/2019, 11:51 PMBigDecimal
. Since it is a Java stdLib object, I don't have access to it. I need to do some pretty high precision math that I don't want to be in base-2, are there any good Kotlin alternatives?Mike R
07/16/2019, 1:29 AMAndrew Gazelka
07/16/2019, 4:38 AMAndrew Gazelka
07/16/2019, 4:56 AMkevindmoore
07/16/2019, 5:01 AMSyed Faraz
07/16/2019, 9:10 AMsealed class Operation <out T> {
data class InsertOperation<out T>(var insertedData: ArrayList<T>)
}
Hi, this gives type parameter t is declared as 'out' but occurs in 'invariant' position in type t
, can anyone tell me what is correct way of handling this type of variance checking?Paul N
07/16/2019, 10:04 AMalex
07/16/2019, 11:57 AM@Value
public final class Url {
@NonNull
private URL url;
@NonNull
private byte[] signature;
}
but in Kotlin it's always treated like ByteArray!
. Apart from that, NonNull is marked with warning: primitive type members cannot be annotated.
Any idea what could be wrong? NonNull annotations are from checker framework.Nikola Milovic
07/16/2019, 4:32 PMJeff
07/16/2019, 5:01 PMJuanoterocas
07/16/2019, 7:20 PMxenoterracide
07/16/2019, 9:38 PMException in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
at com.potreromed.ApplicationKt.main(Application.kt)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I get it when trying to run a very simple application class...
@SpringBootApplication
open class Application
fun main(args: Array<String>) {
runApplication<Application>(*args)
}
Andrew Gazelka
07/17/2019, 12:33 AMbbaldino
07/17/2019, 6:27 AMclass Foo<T> {
...
inner interface FooEventHandler {
fun event(value: T)
}
}
but it looks like this isn't possible (it says inner
can't be used with interface
). is there a good way to accomplish something like this? i don't want the user to have to define the generic type in 2 places (once for Foo and once for instantiating a FooEventHandler, because it could only lead to a mistake)Vladimir Ivanov
07/17/2019, 11:09 AMgregorbg
07/17/2019, 12:05 PMAlexjok
07/17/2019, 12:17 PMNikolai
07/17/2019, 2:27 PMMax
07/17/2019, 3:48 PMmathew murphy
07/17/2019, 4:06 PMJoe
07/17/2019, 5:30 PM?:
elvis operator to provide a default:
If I have reasonable tests around code that does something like:
val x = nullableObject?.method() ?: default
JaCoCo tells me I have one of 4 branches uncovered.
If I change that to:
val nullableX = nullableObject?.method()
val x = nullableX ?: default
JaCoCo tells me all branches are covered (2 branches per line).
I'm guessing the "uncovered" branch is when nullableObject
is non-null, but method()
returns null -- is there a way to get JaCoCo to realize that branch is not possible based on method()
not being nullable? Or is there a better practice here?bbaldino
07/17/2019, 7:51 PMjava.lang.VerifyError: Call to wrong <init> method
Luke
07/17/2019, 8:53 PMJP Wang
07/17/2019, 9:30 PMJP Wang
07/17/2019, 9:30 PMmbonnin
07/17/2019, 9:33 PMJP Wang
07/17/2019, 9:34 PMmbonnin
07/17/2019, 9:34 PMShawn
07/17/2019, 9:36 PMJP Wang
07/17/2019, 10:47 PMalex009
07/18/2019, 1:59 AMribesg
07/18/2019, 7:57 AMepabst
08/02/2019, 12:55 AM