Mike R
08/04/2019, 11:21 PMval queue: Queue<() -> Unit> = LinkedList()
, but I don't think the Queue type will do what I need as I described above. Any recommendations?Dominaezzz
08/04/2019, 11:24 PMqueue.add({ callMethod(arg0, arg2) })
Mike R
08/04/2019, 11:34 PMcallMethod
be executed as soon as I run that?someFunction
, but as soon as I do someFunction()
it gets calledMark Murphy
08/04/2019, 11:36 PMcallMethod()
-- the queue is holding a lambda expression that calls callMethod()
(note the {}
wrapping callMethod(arg0, arg2)
)
callMethod()
will not be called until you invoke()
the lambda expression. Your queue would still be Queue<() -> Unit>
from a data type standpoint, where () -> Unit
is a function type saying "no parameters and return nothing", which is what that lambda expression does.Mike R
08/04/2019, 11:36 PMMark Murphy
08/04/2019, 11:39 PMQueue<() -> Unit>
neither knows nor cares what code is in the lambda expressions. Those can be as simple or as complicated as you need.Mike R
08/04/2019, 11:39 PM