Given:
public enum Endian {
case big, little
}
public enum DataConversionOption {
case encoding(String.Encoding)
case endian(Endian)
}
Can the following be simplified?
init(conversionOptions: Set<DataConversionOption>) {
for option in conversionOptions {
if case .endian(let endian) = option {
number = (endian == .big) ? number.bigEndian : number.littleEndian
}
}
}
Can I use the contains or first (or some other) method of Set to extract the associated value of the Endian enum if the conversionOptions Set contains one?