Bernhard
12/10/2018, 11:40 PMdtos.filter { it.field != null }
.map { OtherDto(it.field!!, it.otherField, it.anotherField) }
Marc Knaup
12/11/2018, 8:46 AMinline fun test(vararg properties: Pair<String, Any?>) {
//(uses pairs)
}
test(
"a" to 1,
"b" to 2,
…
)
Can the compiler optimize away the Pair
allocations and maybe even the boxing?
if so, is inline
needed for that to happen?Andrew Gazelka
12/11/2018, 3:28 PMDias
12/11/2018, 4:51 PMgcx11
12/11/2018, 9:55 PMfun main() {
fun foo() {
bar()
}
fun bar() {
println("Called")
}
foo()
}
jiangxingbing
12/12/2018, 2:08 AMA
extend from a Java class Base
which has a static function f()
. When I called A.f()
in a Kotlin file the IDE give an error ” Unresolved reference: f “. But when I called A.f()
in a Java class, It works fine. I want to know the reason and maybe correct implementation. Thanks!roberto
12/12/2018, 2:54 AMLulu
12/12/2018, 7:39 AMPaul Woitaschek
12/12/2018, 9:34 AMLouis
12/12/2018, 10:46 AMval stringList = somethingList.map {
it.str
}
if (stringList.isNotEmpty()) {
doSomethingWithMyList(stringList)
}
And i would like to do something like that
somethingList.map {
it.str
}.unknownOperation { // here i need help
doSomethingWithMyList(it)
}
arve
12/12/2018, 11:13 AMfun registerService(interface: ???, impl: ???) { ... }
registerService(UserInterface::class, UserService()) // ok
registerService(CarInterface::class, CarService()) // ok
registerService(ChairInterface::class, TableService()) // fail, because TableService does not implement ChairInterface
jkbbwr
12/12/2018, 2:55 PMwakingrufus
12/12/2018, 2:56 PMis
predicate and then doing operations on the subclass further down the chain?tKw
12/12/2018, 3:38 PMdavidasync
12/12/2018, 4:49 PM➜ life-drain git:(master) ✗ ./gradlew build && java -jar build/libs/life-drain-1.0-SNAPSHOT.jar
w: /home/kotl/repo/watchanimeonline/life-drain/src/main/kotlin/com/life/drain/libs/GetMovieUrls.kt: (65, 33): Unnecessary non-null assertion (!!) on a non-null receiver of type List<String>
BUILD SUCCESSFUL in 3s
6 actionable tasks: 6 executed
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/functions/Function1
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.functions.Function1
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)
... 7 more
xenoterracide
12/12/2018, 6:42 PMNick Johnson
12/12/2018, 8:06 PMcrummy
12/13/2018, 6:28 AMval filtered = all.filter { it.foo }
.map {
callFunction(it)
return it
}.toList()
Davio
12/13/2018, 7:34 AMin T
?jonathan
12/13/2018, 8:25 AMEntity
), or not cast it at all.jkbbwr
12/13/2018, 10:42 AMMarc Knaup
12/13/2018, 3:21 PMwathek
12/13/2018, 4:52 PMerror: invalid method declaration; return type required
samir
12/13/2018, 5:21 PMxenoterracide
12/13/2018, 5:52 PMxenoterracide
12/13/2018, 10:54 PMxenoterracide
12/14/2018, 6:48 AMlawlorslaw
12/14/2018, 8:55 AMList<Tide>
where a Tide
has a field tide
that is of type Float
, what is the best way to sort by the tide
field?
I tried tides.sortedBy { it.tide }
but it throws a ClassNotFoundExceptioncueball
12/14/2018, 9:40 AMclass RideException(private val errorCode: ErrorCode, t: Throwable) : Exception(t) {
constructor(errorCode: ErrorCode) : super(errorCode.exceptionMessage)
}
getting error near super
-> primary constructor expectedDominaezzz
12/14/2018, 12:02 PMclass Node(val name: String, val parent: String?)
, I want to find the last node in the list that is a child of a child of a child....... of the first element. How to do this without using `var`s?Dominaezzz
12/14/2018, 12:02 PMclass Node(val name: String, val parent: String?)
, I want to find the last node in the list that is a child of a child of a child....... of the first element. How to do this without using `var`s?Egor Trutenko
12/14/2018, 12:05 PMDominaezzz
12/14/2018, 12:06 PM