There's a large variety of ArrayOr... types. They implement Plotly schema primitives that allow assignemnt of either a single value or an array of values. This is very simple in JavaScript due to lack of strong typing but requires a specialized data type in Swift.
Here's a list of the types that currently exist:
[x] ArrayOrInt
[x] ArrayOrDouble
[x] ArrayOrString
[x] ArrayOrAnything
[x] ArrayOrColor
These types duplicate a lot of boilerplate code between each other. It's worthwhile investigating a possibility of replacing them with a single generic ArrayOr<Type> type. Ideally, this type would be as transparent as possible to users and should allow initialization from all meaningful literals via conformance the ExpressibleBy...Literal protocols from the standard library.
Potential pitfall is that a particular type can only conform to a protocol once. Even in cases with different conditional conformance. This would mean that only one of the specialized Type cases would be expressible for example by an Int literal even tough both ArrayOrInt and ArrayOrDouble could meaningfully benefit from it.
There's a large variety of
ArrayOr...
types. They implement Plotly schema primitives that allow assignemnt of either a single value or an array of values. This is very simple in JavaScript due to lack of strong typing but requires a specialized data type in Swift.Here's a list of the types that currently exist:
These types duplicate a lot of boilerplate code between each other. It's worthwhile investigating a possibility of replacing them with a single generic
ArrayOr<Type>
type. Ideally, this type would be as transparent as possible to users and should allow initialization from all meaningful literals via conformance theExpressibleBy...Literal
protocols from the standard library.Potential pitfall is that a particular type can only conform to a protocol once. Even in cases with different conditional conformance. This would mean that only one of the specialized
Type
cases would be expressible for example by anInt
literal even tough bothArrayOrInt
andArrayOrDouble
could meaningfully benefit from it.