0
我試圖訪問一個字符的字符串,但我發現了以下錯誤:斯威夫特:無法下標類型的值又名「陣列<Character>」
error: cannot subscript a value of type 'Array<_Element>' (aka 'Array<Character>')
finalString = characters [ 5 ]
這裏是我的代碼:
//我的字符串:
var str = "Hello, playground"
//我的字符串轉換成字符數組:
let characters = Array(str.characters)
// string這裏我要轉移的角色:
var finalString:String
finalString = characters [ 5 ]
但在最後一行代碼是我得到的錯誤。你們中的任何一個人都知道我在做錯什麼或解決這個錯誤的方法。
我會很感激你的幫助