jw
03/15/2019, 1:33 PMtschuchort
03/15/2019, 6:19 PMGarouDan
03/15/2019, 10:23 PMorg.jetbrains.kotlin.gradle.plugin.KotlinCompilation
we have 3 implementations for defaultSourceSet
,
But how can I use something like org.jetbrains.kotlin.gradle.plugin.KotlinCompilation::defaultSourceSet
with the arguments
configure: KotlinSourceSet.() -> Unit
?LeoColman
03/15/2019, 10:31 PMMarc Knaup
03/16/2019, 12:14 AM@JvmName
on an open
function? 😮Hexa
03/16/2019, 12:26 AMunchecked casts
warning on these lines (json["test"] as MutableMap<String, Any>)["nodes"] as java.util.ArrayList<MutableMap<String, String>>
. Example import com.fasterxml.jackson.databind.ObjectMapper
private fun parseCarId(response: String): String {
val json = ObjectMapper().readValue(response, Map::class.java) as MutableMap<String, Any>
val cars = (json["test"] as MutableMap<String, Any>)["nodes"] as java.util.ArrayList<MutableMap<String, String>>
val first: MutableMap<String, String> = cars.first { it["carType"] == "tesla" }
return first["id"].orEmpty()
}
. I tried something like this so far but now Im getting a compile time error private fun parseCarId(response: String): String {
val json = ObjectMapper().readValue(response, Map::class.java) as MutableMap<String, Any>
val cars = (json["test"] as MutableMap<*, *>)["nodes"] as java.util.ArrayList<*>
val first: MutableMap<String, String> = cars.first { it["carType"] == "tesla" }
return first["id"].orEmpty()
}
GarouDan
03/16/2019, 4:26 PMbackticks
?
Until now we have the following:
val ` -!"#$%^&()*+,-=?@^_{|}~😡` = ""
Characters known to be not allowed:
.:/\[]<>
Is there a place that we can find this?
Related topics:
https://gist.github.com/Danilo-Araujo-Silva/36814f87cdf71177571e817aee040096
https://kotlinlang.org/docs/reference/java-interop.html#escaping-for-java-identifiers-that-are-keywords-in-kotlin
https://kotlinlang.org/docs/reference/coding-conventions.html#naming-rules
https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.2.2
https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.2Dico
03/16/2019, 10:22 PM@file:DependsOn("group:artifact:version")
and not getting reference errors.
See https://blog.jetbrains.com/kotlin/2018/09/kotlin-1-3-rc-is-here-migrate-your-coroutines/#ScriptingLulu
03/17/2019, 5:50 AMApple / Apple
when seen together. The question is, what should I name the core repository to be consistent with kotlin ecosystem? Should it be Apple / AppleCore
, Apple / Core
, Apple / apple
, Apple / apple-core
, or some other name?Hexa
03/17/2019, 9:19 AMgetProperty
function in this case be best declared inline
? fun main() {
val someHashMap = mapOf("first" to Account1("test", "1234"))
println(getProperty("first") {someHashMap.getValue(it).number})
}
fun getProperty(name: String, action: (String) -> String) : String{
return action(name)
}
class Account1(val name: String, val number: String)
I checked the decompiled Java bytecode but I can't work out why inline is better? Is it because in the none-inline
it calls the getProperty
function in the main
like in here? https://gist.github.com/rinnegan/4233b6a242b5f2864e0737b186b45df7#file-inline-vs-none-inline-L33Nir Golan
03/17/2019, 9:35 AM.let
check for uninitialized too?Iaroslav Postovalov
03/17/2019, 12:10 PMBruno_
03/17/2019, 12:18 PM"implementation"
and implementation
? either I can't use search engine or noone explains it
https://docs.gradle.org/5.0/userguide/multi_project_builds.html#sec:project_jar_dependenciestseisel
03/17/2019, 1:17 PMList<E>
to List<Foo>
(or List<Bar>
) in the code below ?vpriscan
03/18/2019, 9:07 AMlateinit
modifier is to be renamed to late
spand
03/18/2019, 10:44 AMrun { ... }
to fun <name>(param1, ...) { ... }
The extract function gives me fun <name>(param1, ...) = { ... }
which also happens to break any return@run
amadeu01
03/18/2019, 12:58 PMwith
when the variable é optional? for instance,
inside a fragment, the activity
is optional, so can I use something like
private fun goToMain() = with(activity) {
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finishAffinity()
}
aballano
03/18/2019, 1:35 PM[1, 2, 3]
and [4, 5, 6, 7]
is there an existing function that intercalates both so the result is [1, 4, 2, 5, 3, 6, 7]
?ghedeon
03/18/2019, 3:31 PMsealed class DialogState(open val title: String, open val text: String) {
data class ConfirmDelete(override val title: String, override val text: String) : DialogState(title, text)
data class CantDelete(override val title: String, override val text: String) : DialogState(title, text)
}
tipsy
03/18/2019, 4:03 PMfilter
smart cast ?
connectors.filter { it is ServerConnector }.map { it as ServerConnector } // why is map needed here?
maybe there's a better solution for this?Sola
03/18/2019, 4:17 PMPaul Woitaschek
03/19/2019, 8:42 AMGuru
03/19/2019, 12:16 PMGuru
03/19/2019, 12:18 PMGuru
03/19/2019, 12:20 PMJukka Siivonen
03/19/2019, 1:24 PMGarouDan
03/19/2019, 4:34 PMClosure a = { /*...*/ }
Closure b = { /*...*/ }
Closure c = a << b
How can we do that in Kotlin? Merging closures or high order functions?
I’m trying something like:
val a : KotlinSourceSet.() -> Unit = {
dependencies {
implementation(kotlin("stdlib-js"))
}
}
val b: KotlinSourceSet.() -> Unit = {
dependencies {
implementation(project(":common", "jvmApiDefault"))
}
}
where the result that I expect is something like:
val c: KotlinSourceSet.() -> Unit = {
dependencies {
implementation(kotlin("stdlib-js"))
implementation(project(":common", "jvmApiDefault"))
}
}
But how can we properly create the variable c
?Stefan Peterson
03/19/2019, 5:05 PMpoohbar
03/19/2019, 5:47 PMinstance
nullable, i just want simpleName
to return ""
in that case.. but even wrapping it in if (instance != null)
does not helpxenoterracide
03/19/2019, 7:48 PMlist.map { arrayOf(it.rfid.rfid, it.pressureSignal, it.uoPressure, it.chamberPressure, it.ultrasonicSignal, it.rfid.timestamp) }
given this map, I want to flatten the whole list into one big array (no nested arrays), but I’m not sure how to take each element of this array and map it to just an element