[swift-evolution] Potential problamatic initializers, solved by removing tuple splat?

Jens Persson jens at bitcycle.com
Sun Feb 7 07:45:05 CST 2016


let tenXs = String(count: 10, repeatedValue: Character("X"))
let tenYs = String(count: 10, repaetedValue: Character("Y"))
print(tenXs) // Prints XXXXXXXXXX
print(tenYs) // Prints (10, "Y")

So, why doesn't tenYs print the expected YYYYYYYYYY?
- Because of the slightly misspelled repeatedValues parameter label.

Then why no compile time error for the misspelled parameter label?
- Because of this String intializer: public init<T>(_ instance: T)

I guess there are other similar examples, but I happened to stumble upon
this one just now.

Should they be considered a problem?

Is this an example of a problem that will be solved by removing tuple splat?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160207/5c9fb391/attachment.html>


More information about the swift-evolution mailing list