string - Does Swift init(count:, repeatedValue:) work? -


tested reference: https://developer.apple.com/documentation/swift

var string = string(count: 5, repeatedvalue: "a") // string "aaaaa" 

i got error:

playground execution failed: error: :5:14: error: not find overload 'init' accepts supplied arguments var string = string(count: 5, repeatedvalue: "a")

does work?

it seems have explicitly pass in character type function. works me.

let char = character("a") let string = string(count: 5, repeatedvalue: char) 

although, there may bug mixed in well. believe way doing should have worked on own. , can't seem code completion on initializer @ all.

edit: i'm going bug. following compiles fine.

let array = array(count: 5, repeatedvalue: "a") 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -