Potential problamatic initializers, solved by removing tuple splat?

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?

Looks like some kind implicit tuple "unsplating", the reverse of what is mentioned in SE-0029: Removing implicit tuple splat

class sample
{
    init<T>(_ instance: T)
    {
        print(instance)
    }
}

let tenYs = sample(count: 10, repaetedValue: Character("Y"))

does display the same (10, "Y").

Dany

···

Le 7 févr. 2016 à 08:45, Jens Persson via swift-evolution <swift-evolution@swift.org> a écrit :

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?