Is there a way to do this as an extension to Array as opposed to a switch statement that's going to grow and grow?
fileprivate var exteriorColorOptions = [ExteriorColorOption]()
fileprivate var otherOptions = [SomeOtherOption]()
: more options
func add(option:FilteredOption) {
switch(option) {
case let thing as ExteriorColorOption:
exteriorColorOptions.append(thing)
case and on and on
default:
break
}
}
I would like to be able to just do the following with the right extension in place:
exteriorColorOptions.appendIfPossible(option)
otherOptions.appendIfPossible(option)
Note: switch approach came from Swift: Test class type in switch statement