Hello,
It is probably something very stupid that I should know, but I have not been able to find an expalnation. Neither in this forum, nor in Stackoverflow.
Below an example of code from the developper documentation:
let name = "Marie Curie"
let firstSpace = name.index(of: " ") ?? name.endIndex
let firstName = name[..<firstSpace]
// firstName == "Marie"
When pasting this examples into xcode I get the error below.
(I get the same errors in playground, and if I insert it in a more elaborate context like the body of a button action.
The first and second errors are "Cannot use instance member 'name' within property initializer; property initializers run before 'self' is available"
Any help will be appreciated
Thanks
Lars