This isn't a fully formed pitch, and maybe already discussed, but... If we have have optionals and non-optionals, shouldn't we also have a way to declare that an Array never be empty? It seems like this would naturally lead to more elegant designs.
Here's a use-case: struct Wavelet { var buff: [Double] var sign: Sign var peak: Double { return buff.find_max()! // <-- Yuck! } } In my app, I never want to create an empty "buff" here. If I could declare that the Array always contain at least 1 element, I wouldn't need to worry about a whole bunch of unwrapping elsewhere in my program. Native ability to do this would also be handy to store chunks of memory, too? Would this be worthwhile?
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution