Closed jreut closed 7 years ago
That's correct. Task.waitAll([])
would resolve to the empty array. Originally this (and Task.waitAny
) were designed for the static case, where you know which tasks you're passing there, so an empty array is an obvious error. But that's not necessarily the case for a dynamic case, where you get an arbitrary array containing tasks from elsewhere, and you might want to resolve that to an empty array if they're empty.
I don't really feel strongly either way, so this behaviour could change to support the latter use case. My only reservation right now is with Task.waitAny
not having a similar empty value, and thus Task.waitAll([])
wouldn't throw an error, whereas Task.waitAny([])
would have to, since returning a Task that never resolves there would make finding accidental empty arrays difficult.
Task.waitAll([])
fails with an error saying it requires a non-empty array of tasks. To my mind,Task.waitAll([])
is a Task that will always resolve to[]
, just likeTask.waitAll([Task.of(42)])
is a Task that will always resolve to[42]
.I might be missing something, though. What is the motivation behind failing on an empty array? I'm happy to submit a patch if this behavior could indeed be changed.
Thanks!