bbaldino
11/06/2019, 8:18 PMKonstantin Petrukhnov
11/07/2019, 9:33 AMval cache = MutableMap<String, Any?>
where value could be String, Int, Map, Array, etc.
Then i retrieve values from it through the chain of functions, where caller is responsible to specify correct type.
cache[key] as R?
Question: what problems I may get with that approach? All of this code is internal to the module, and run on jvm/ios.oday
11/07/2019, 10:28 AMKonstantin Petrukhnov
11/07/2019, 2:02 PMval myvalue: MyObj by lazy {...}
, how I could inject different object to myvalue during testing?Konstantin Petrukhnov
11/08/2019, 12:03 PMgregorbg
11/08/2019, 3:40 PMList<Int>
where every entry is a counter. What would be a Kotlin-esque way to map this into a List<Int>
where at every index the entry is equal to the sum of counts until that index? For example, [1, 3, 4, 2, 2]
becomes [1, 4, 8, 10, 12]
due to the following summations: [1, 1+3, 1+3+4, 1+3+4+2, 1+3+4+2+2]
Pallavi
11/10/2019, 3:48 PMdoSomething
?
//Way 1 (doSomething is a member function)
data class A(val item: String) {
fun doSomething(): String{
return item.toUpperCase()
}
}
//Way 2 (making doSomething an extension function)
data class A(val item: String)
fun A.doSomething(): String {
return item.toUpperCase()
}
Frodrigues
11/10/2019, 5:32 PMTerje Andersen
11/11/2019, 8:25 AMList<Map<String, List<T>>>
to Map<String, List<T>>
. If the original list of maps contain two maps containing the same String key, the lists should be merged / concatenated. I finding it hard to achieve this, could anyone nudge me in the right direction?dG
11/11/2019, 10:30 AMif (someArray[x] != null) { someArray[x].add(foo) }
Why does the compiler not recognize that someArray[x]
cannot be null, and insists on !!
?Vishnu Haridas
11/11/2019, 1:34 PMatsushi-koshikizawa
11/12/2019, 6:13 AMdata class Hoge(val foo: String, val bar: String)
data class Fuga(foo: String, bar: String, val buz: String) : Hoge(foo, bar) // compile error
Data class in Kotlin cannot be opened, and its primary constructor must have only property parameters.
I have two questions.
1. Why cannot data classes be opened?
2. How can I reuse Hoge
class to define Fuga
class?Mr.NiceGuy
11/12/2019, 8:11 AMEsa
11/12/2019, 8:24 AM.csv
-file, and want to be as explicit as possible.
The file comes in a strict format, and I am able to say for sure what content-type each column will have. For this reason, I want to model it explicitly, like so:
sealed class CsvField {
data class ExternalId(val value: String) {
companion object {
const val index: Int = 0
}
}
}
So obviously there will be many more columns, which means the sealed class ends up looking extremely verbose when every data class has its own companion object, and there are like 15 of them.
So back to my question; when my intent is to have 1 subclass of a sealed class with 1 constant, unchangeable field and one specified in constructor, is this the best way? Or am I missing something obvious? Is there a better pattern here? I tried with enum class
first, but that way I don’t get to specify the value of the field, only the expected data. I could have a data class with the enum as type, and a plain string as value, but idk. Thoughts?Oleh Ponomarenko
11/12/2019, 11:00 AMvar isStopped =false
do {
}while (isStopped.not())
Shumilin Alexandr
11/13/2019, 7:26 AMFlorian
11/13/2019, 8:43 AMJoey
11/13/2019, 9:07 AMTuang
11/13/2019, 1:38 PMShumilin Alexandr
11/13/2019, 2:51 PMShizo
11/13/2019, 10:52 PMCannot transform this request's content to org.user5145.account.domain.aggregate.Account
https://pastebin.com/LZmcMx1u
PS. it uses ktormagnumrocha
11/14/2019, 8:38 AMdf
11/14/2019, 10:22 PMreturn if (sortedItems.isEmpty()) null else itemMapper.mapDto(sortedItems.first())
Esakki
11/15/2019, 11:47 AMJur
11/15/2019, 8:39 PMMr.NiceGuy
11/17/2019, 5:31 PMJoey
11/18/2019, 6:46 AMjubril
11/18/2019, 9:11 AMJoey
11/18/2019, 9:29 AMEllen Spertus
11/18/2019, 7:32 PMwhen
as an expression, can there be multiple statements in an arm?