testato questo dal di riferimento: https://developer.apple.com/documentation/swiftSwift init (count :, repeatValue :) funziona?
var string = String(count: 5, repeatedValue: "a")
// string is "aaaaa"
ho ottenuto questo errore:
Playground execution failed: error: :5:14: error: could not find an overload for 'init' that accepts the supplied arguments var string = String(count: 5, repeatedValue: "a")
fa questo in realtà funziona?
Questo funziona! È strano che Swift Reference Guide abbia commesso un errore così grande. –
Sembra che ripetutoValore deve essere un tipo di carattere, ma non esiste un modo ovvio per rendere un carattere letterale in Swift (in C, useresti le virgolette singole piuttosto che le virgolette doppie). –
La guida non è rotta, il motore di inferenza del tipo è. L'abbonamento è un primo esempio in cui cade a vuoto sul suo volto pur avendo tipi veramente espliciti. – CodaFi