corneil
09/12/2019, 11:57 AMAkhil Suseelan
09/12/2019, 2:15 PMMutableMap<String, Dequeue<String>>
to MutableMap<String, Array<String>>
Florian
09/13/2019, 7:45 AMUnit
functions, right?Johan Alkstål
09/14/2019, 5:07 PMFlorian
09/15/2019, 9:22 AMtipsy
09/15/2019, 6:22 PMINSTANCE
on objects (the one that's visible from java)?theopaintsil
09/15/2019, 6:32 PMSoren Valle
09/15/2019, 6:48 PMclass SomeClass {
var someProp: Any? = null
}
fun main() {
val someClass = SomeClass()
someClass.someProp = {
println("I do things")
}
// else where
if(someClass.someProp is Function<*>){
someClass.someProp() // invoke not found...
}
}
Jacob Richards
09/15/2019, 9:08 PMGreg Stepniewski
09/16/2019, 11:34 AMsuspend fun loadTwoThings() = coroutineScope {
val job1 = async { getDataOne() }
val job2 = async { getDataTwo() }
saveData(job1.await(), job2.await())
}
different from this
suspend fun loadTwoThings() = {
val job1 = async { getDataOne() }
val job2 = async { getDataTwo() }
saveData(job1.await(), job2.await())
}
As I understand, if I cancel a coroutine that called loadTwoThings
, without coroutineScope the two async will keep running. Also, if one async fails it will let the other keep running.
Why is that? A failed child is supposed to cancel its parent, and a cancelled parent is supposed to cancel its children. Are the two asyncs not children of the main coroutine? What exactly does coroutineScope
do that makes a difference?bitkid
09/16/2019, 11:39 AMlistOf(Pair("a","b"), Pair("a","c"), Pair("b","d"))
to mapOf("a" to ["b","c"], "b" to "d")
?martin
09/16/2019, 4:44 PMclass Person(val name: String, val lastName: String)
class Employee(val name: String, val lastName: String): Person(name, lastName)
but is there a way to have that Employee class just inherit all the properties of Customer, without listing them all explicitly as properties ? my guess is no, but I may be missing somethingRan Magen
09/16/2019, 4:56 PM(T) -> (R?)
and then mapNotNull
? That'd work (assuming T : Any
) but it would create an intermediate list, which ideally I'd like to avoid.spicyspiders
09/17/2019, 2:19 AM@Column(nullable = false)
val locationId: String?,
- if the db schema defines not null, does it make sense to mark the data class field as nullable? What is the behaviour in such a case?vineethraj49
09/17/2019, 5:16 AMwithTimeoutOrNull
not work with readBytes
?
example, this always works (and I’m pretty sure 1ms val bytes = withContext(<http://Dispatchers.IO|Dispatchers.IO>) {
withTimeoutOrNull(1) {
URL(urlPath).readBytes()
}
}
Esa
09/17/2019, 12:55 PMclass xyzService.kt
).
In this service, i have several private values.
Now, for the usecase I’m trying to solve in this service, I wanted to have an abstract inner class Action
which has 1 more layer of inner classes, like inner class Action.Cancel
, Action.Start
etc (actual usecases are a bit more complex but I guess this translates okay). Each of these inner classes should also have access to the values in the top level service class.
Then from the service class (but outside the Action class) I wish to be able to do Action.Cancel().execute()
(execute is an overridden function from the superclass). However, I seem to run into some issues with these visibility modifiers. When attempting to interact with the values in the top level service class, I get the following:
Constructor of inner class Start can be called only with receiver of containing class
.
Am I using the wrong hierarchy here? What’d be more appropriate? Does this seem like a wrong way to do things?Florian
09/18/2019, 9:11 PMspicyspiders
09/19/2019, 2:27 AMpeople: List<Person>?
is it safer to do people: List<Person?>?
instead? i.e. people field can be null and also list containing null or empty?Florian
09/19/2019, 7:54 AMFlorian
09/19/2019, 9:47 PMJohan Alkstål
09/20/2019, 5:32 AMJames Richardson
09/20/2019, 5:21 PMMatthew Holmes
09/21/2019, 4:53 PMFlorian
09/21/2019, 7:02 PMSlackbot
09/23/2019, 11:48 AMFlorian
09/23/2019, 5:06 PMvararg
function with an Array
of the same type because the vararg is internally represented as an array on the JVM? (I know I can use the spread operator)spicyspiders
09/24/2019, 12:26 AMursus
09/24/2019, 4:41 AMFlorian
09/24/2019, 8:00 PMFlorian
09/25/2019, 8:34 AMvararg
parameters are not allowed even if they have different typesFlorian
09/25/2019, 8:34 AMvararg
parameters are not allowed even if they have different typesLuca Nicoletti
09/25/2019, 8:46 AMvararg
must be the last parameter, so, having 2 of them is not possible as only the latter would really be the last oneFlorian
09/25/2019, 9:19 AMLuca Nicoletti
09/25/2019, 9:19 AMFlorian
09/25/2019, 1:49 PM1, 2, 3, "bla", "blubb"
to a function with an Int
and a String
vararg
Ruckus
09/25/2019, 3:27 PMinterface A
interface B
class AI : A
class BI : B
class AB : A, B
fun x(vararg a: A, vararg b: B) { ... }
x(AI(), AB(), BI())
Where is the division line?
That's a simple example. It can get far more complicated, and that's even without taking things like generics into account.Florian
09/25/2019, 9:24 PMRuckus
09/25/2019, 10:46 PMFlorian
09/26/2019, 6:50 AM