extension Unicode {
// An example of the option language in declaration context,
// with nil defaults indicating unspecified, so defaults can be
// driven by the presence/absence of a specific Locale
func frobnicated(
case caseSensitivity: StringSensitivity? = nil,
diacritic diacriticSensitivity: StringSensitivity? = nil,
width widthSensitivity: StringSensitivity? = nil,
in locale: Locale? = nil
) -> Self { ... }
}
```
Any reason why Locale is defaulted to nil, instead of currentLocale? It
seems more useful to me.
The reason is given in the text above the code sample: "The defaults for
case-, diacritic-, and width-insensitivity are different for localized
operations than for non-localized operations, so for example a localized
sort should be case-insensitive by default, and a non-localized sort
should be case-sensitive by default."
So the API would need to distinguish between "current locale" and "no
locale" (i.e. use the non-localized algorithm).
Will String also conform to SequenceType? I’ve seen many users (coming
from other languages) confused that they can’t “just” loop over a
String’s characters.
Collection refines Sequence, so all collections are sequences. This
would also be true for String. So yes, you could do `for char in string`
again.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution