[swift-evolution] Strings in Swift 4
Bernd Ohr (jazzbox)
jazzbox at 7zz.de
Sun Jan 22 01:45:18 CST 2017
> Am 21.01.2017 um 21:31 schrieb Dave Abrahams via swift-evolution <swift-evolution at swift.org>:
>
>> I'm struggling a little with the naming and syntax, but as a general approach, I think we want people to use something more like this:
>>
>> if StringOptions(case: .insensitive, locale: .current).compare(foo < bar) { … }
>
> Yeah, we can't do that without making
>
> let a = foo < bar
>
> ambiguous
>
Hi,
the most swifty way to write this I can imagine is something like:
func <(_ a: Int, _ b: Int, case: Case = .insensitive, locale: Locale = .current)
let a = foo < bar where <(case: .insensitive, locale: .current)
In other words, function or operator calls can be splitted:
func foo(_ a: Int, _ b: Int, option: Option)
let res = foo(10, 20) where foo(option: .fast)
And where it is unambiguous the second function or operator name can be omitted:
let a = foo < bar where (case: .insensitive, locale: .current)
...or shared:
let a = foo1 < bar1 && foo2 < bar2 where (case: .insensitive, locale: .current)
— Bernd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170122/57fbc837/attachment.html>
More information about the swift-evolution
mailing list