From udacity course I am trying below code
let password = "Meet me in St. Louis"
let newPassword = password.replacingOccurrences(of: "e", with: "3")
This is giving
Playground execution failed: Introduction.xcplaygroundpage:31:19: error: value of type 'String' has no member 'replacingOccurrences'
let newPassword = password.replacingOccurrences(of: "e", with: "3")
^~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
Forcefully I have to use
let password = "Meet me in St. Louis"
let newPassword = password.stringByReplacingOccurrencesOfString("me", withString: "ss")
Any clue why this error coming? I am using swift version 2.2
In case you run this code example from the command line (by running Swift REPL), add import Foundation at the beginning of your .swift file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With