Handling Expression empty arrays
Environment
- Xcode version: 14.3.1
- Maps SDK Version: 10.15.0
Observed behavior and steps to reproduce
It has always been a nightmare to manage match expressions with arrays, which could be empty (which leads to a crash with an error "Expected at least one branch label").
Now, when there's a "type safe"Exp, it became even harder (while overall Exp has much better usage), since there's no instrument to create Exp dynamically in any means. E.g. allowing closures inside it:
Error: Trailing closure passed to parameter of type '[Expression.Argument]' that does not accept a closure
let expression = Exp(.match) {
Exp(.get) { "objectId" }
if !yellowObjectIds.isEmpty {
yellowObjectIds
UIColor.yellow
}
blueObjectIds
UIColor.blue
UIColor.white
}
Expected behavior
Ideally, it would be useful to cover such cases inside wrapped Exp, so there would be no struggle. Or at least have any instrument of dynamic creation of Exp
Notes / preliminary analysis
Maybe there are already some instruments to cover my case, which I couldn't find in documentation. I would be very grateful, if somebody points me in the right direction.
Additional links and references
I found an old issue in js repo about the same problem, but before Exp were introduces
Hi @Ogerets --
Thanks for sharing this report. To help us take a deeper look, can you share a project which reproduces the issue you are describing? Additionally, can you share what your overall use case is?