karelpeeters
06/01/2018, 10:44 AMwarriorprincess
06/01/2018, 11:00 AMminBy
actually give a reference to original object? I do lowest = lowest?.next
in my code above, does it actually move the head
of the list stored in lists
?aandreyev
06/01/2018, 12:21 PMFuyang
06/01/2018, 1:23 PMnull
get into map values from json string? https://stackoverflow.com/questions/50643864/kotlin-how-to-prevent-null-gets-into-map-object-during-jackson-json-deserializ
Much appreciated 🙂selva
06/01/2018, 2:31 PMwarriorprincess
06/01/2018, 7:27 PMfun mergeKLists(lists: Array<ListNode?>): ListNode? {
var holder: List<ListNode?> = arrayListOf()
while (true) {
val bulk = lists.withIndex().minBy { (_, value) -> value?.`val` ?: Int.MAX_VALUE }
val index = bulk?.component1(); val lowest = bulk?.component2() ?: break
holder += lowest
lists[index!!] = lists[index]?.next
}
for (index in 1 until holder.size) holder[index-1]?.next = holder[index]
return if (holder.isNotEmpty()) holder[0] else null
}
warriorprincess
06/01/2018, 7:28 PMRoman Dzhadan
06/02/2018, 9:30 AMorg.jetbrains.kotlin:kotlin-maven-plugin:1.2.41
>> Unknown JVM target version: 10. Supported versions: 1.6, 1.8
Is there any chance to run JVM 10 with Kotlin 1.2?kenkyee
06/02/2018, 9:40 AMHamza
06/02/2018, 10:42 AMkarelpeeters
06/02/2018, 2:06 PM#33244c,#423393,#944c94,#FFFFFF,#423393,#FFFFFF,#944C94,#F88909
thomasnield
06/02/2018, 6:18 PMSequence
flatMap()
be bad for performance when you need to recurse a larger number of items (e.g. 1000, 10000)? Should I be doing a loop with tailrecur
instead?coder82
06/02/2018, 10:22 PMmik_os
06/03/2018, 7:25 PM-------------------
Language code
-------------------
Java 42659
Kotlin 8834
Task compile<Flavor>Kotlin
takes 25s
Task compile<Flavor>JavaWithJavac
takes 8s
Is this something I should report to bugtracker? Or 14x (3x more time for 4.6x less code) slower kotlin compilation have some reasonable explanation?tschuchort
06/03/2018, 8:58 PMfun <T> foo(t: T, setProp: T.(Int) -> Unit, getProp: T.() -> Int) = t.apply { setProp(getProp() + 1) }
but what I want to do is:
fun <T> foo(t: T, prop: Property<T,Int>) = t.apply { prop += 1 }
lawlorslaw
06/04/2018, 8:40 AMkotlin-koans
repo is the problem. Every time you make a change to a test you have to rerun the testClasses
Gradle task.karelpeeters
06/04/2018, 9:00 AMBenoit Duffez
06/04/2018, 11:41 AMEntity
) that is inherited from two children, and they need to change the type of one property.
This is because these classes are used to retrieve data from a backend (in serialized in JSON, deserialized with Gson). In fact, the server uses the same object for downlink (e.g. GET /x/y/z.json
returns a list of Entity
) and uplink (POST /abc
with one Entity
in the body), but one of the fields has not the same type whether it's uplink or downlink (bummer... I can't change the server code...).
So in Entity
i have declared the property as open var stuff: Any? = null
, and I expected the EntityUplink
for example to have override var stuff: ActualType? = null
but the compiler refuses that.
Is that a violation of the language (e.g. not possible/not designed to do that) or am I missing something?BorzdeG
06/04/2018, 3:23 PMabstract class DemoSuper() {
protected fun getProperty(defaultValue: String): String {
// field name?
return defaultValue
}
}
class Demo : DemoSuper() {
val f0: String by lazy { getProperty("f0") }
val f1: String by lazy { getProperty("f1") }
}
karelpeeters
06/05/2018, 9:57 AMproperty.returnType
.edwardwongtl
06/05/2018, 10:15 AMtschuchort
06/05/2018, 10:18 AMKiller -> A
function to a Test -> A
function but it's somewhat annoying to usenwh
06/05/2018, 1:14 PMdata class Example(val name: String?)
Let's say I have an Example("")
, but I want blank strings to be null. I can do:
ex.copy(name = if (name.isBlankOrNull()) null else name)
But this requires hard coding. Is there a safe way to process all the fields like this?gyl
06/05/2018, 3:36 PMobject
classes ?
We would like, for each test, re init a lateinit var foo
property with different values a on our singleton, but actually, once it is initialized once, we found no way to reinit the singleton.
Sorry for my english..bdawg.io
06/05/2018, 4:39 PMIntArray
and Array<Int>
? If so, is there a reason why the compiler doesn’t treat them as type aliases?adams2
06/05/2018, 6:17 PMSeri
06/05/2018, 8:43 PMjmccance
06/05/2018, 8:50 PMx
and call copy
on x
, I expect to be able to call the same functions on the copy as I could on x
.”david-wg2
06/06/2018, 8:44 AMAndrei
06/06/2018, 9:09 AM