Trying to get a substring String and add it to an array of strings:
var stringToSplit = "TEST TEXT" var s = [String]() let subStr = anotherString[0 ..< 6] s.append(subStr) // <---- HERE I GET THE ERROR
As @Leo Dabus mentioned, you need to initialize a new String with substring :
new String
substring
Edit:
s.append(subStr)
To:
s.append(String(subStr))
Source: https://habr.com/ru/post/1272028/More articles:declare constants in golang using the results of os.Getenv in the const initializer in os.Getenv ("MY_SECRET") is not a constant '- goView on status bar in iPhone X simulator is distorted - iosRegex is not a โpermanentโ bug in Golang - regexEclipse Oxygen - problem with adding JRE / JDK 9 - javaInstalled path with chrome head in CentOS 7 - linuxMySQL vs MariadB: general error: 1205 lock timeout exceeded; try restarting the transaction - mysqlHow to get and process mysql records using Airflow? - python-3.xHow to cover sdl2 fps like pygame - c ++Unable to insert object into json object array - jsonUIKeyboardWillChangeFrame is not called on iOS 11 (when switching to view controllers) - iosAll Articles