tipsy
05/02/2018, 2:14 PM@FunctionalInterface
interface JsonToObjectMapper {
fun <T> map(json: String, targetClass: Class<T>): T
}
var jsonToObjectMapper = object : JsonToObjectMapper { // use lambda here somehow?
override fun <T> map(json: String, targetClass: Class<T>): T {
}
}
according to this SO post (https://stackoverflow.com/questions/22588518/lambda-expression-and-generic-method/22588738#22588738) you can't combine generics and lambdas in java, but is it possible to achieve in kotlin somehow?adam-mcneilly
05/02/2018, 2:34 PMError:(6, 6) Cannot access 'OnlyInputTypes': it is internal in 'kotlin.internal'
Slackbot
05/02/2018, 2:54 PMmarcinmoskala
05/02/2018, 6:01 PMrobstoll
05/02/2018, 6:07 PMfun <T> foo(t: T){
val i: (T) -> T = { it }
}
benleggiero
05/03/2018, 2:57 AMhttps://i.imgur.com/fDwYP3f.png▾
v79
05/03/2018, 8:46 AMdroidrcc
05/03/2018, 9:33 AMubu
05/03/2018, 6:50 PMMarharyta Nedzelska
05/03/2018, 7:43 PMadams2
05/03/2018, 8:13 PMadams2
05/03/2018, 8:17 PMjw
05/03/2018, 8:21 PMRandomAccessFile
I have subclassed it and returned false
from delete()
orangy
05/03/2018, 8:23 PMfun fileManipulationCode(file: File) {
when (file.deleteRecursively()) {
true -> reportSuccess()
false -> doSomethingElse()
}
}
then you can test doSomethingElse
separately.Slackbot
05/03/2018, 10:07 PMcprigent
05/04/2018, 12:59 PMrobstoll
05/04/2018, 2:02 PMfun <R> (() -> R).evalOnce(): () -> R {
val v by lazy { this() }
return { v }
}
but which works also for functions with one or more parameters?diesieben07
05/04/2018, 2:12 PMJoeywp
05/04/2018, 7:22 PMrobstoll
05/05/2018, 10:17 AMArray
but not for `Collection`/`Iterable`?tipsy
05/06/2018, 4:56 PMfromJson(JsonToObjectMapper jsonToObjectMapper)
(java), which configures how my library does json-mapping:
public interface JsonToObjectMapper {
<T> T map(String json, Class<T> targetClass);
}
calling this method works fine from java, but kotlin is unable to infer types. if i try to to:
val gson = GsonBuilder().create()
myPlugin.fromJson(gson::fromJson)
i just get None of the following functions can be called with the arguments supplied.
any ideas?diesieben07
05/07/2018, 9:14 AMlist.associate { key to value }
or list.associateBy { key }
selckin
05/07/2018, 9:22 AMErfan
05/07/2018, 1:00 PMvar items: Array<T> = ?
I wanted to use arrayOf<T>()
but this doesn't work.osamarao
05/07/2018, 6:15 PMkapt.kotlin.generated
is pointing to. In my case its in /generated/source/kaptKotlin/
When you want to access the generated functions, android cannot find them unless you add to your build.gradle
android {
…
sourceSets {
main {
java {
srcDir "${buildDir.absolutePath}/generated/source/kaptKotlin/"
}
}
}
}
is there a way to avoid this?jdemeulenaere
05/07/2018, 6:16 PMCzar
05/07/2018, 9:44 PMJoeHegarty
05/07/2018, 11:28 PMcfleming
05/08/2018, 12:25 AMpublic interface MyInterface {
String getText();
}
I can’t seem to use:
class MyClass(val text: String): MyInterface
elect
05/08/2018, 1:31 PMelect
05/08/2018, 1:31 PMilya.gorbunov
05/08/2018, 2:42 PM