在尝试使用变量声明我想要读取的元素时,我一直收到此错误。我到处寻找解决方案,但我无法找到适合我特定情况的解决方案,任何帮助都将不胜感激。提前谢谢。
getListOfFiles::FilePath -> IO [FilePath]
getListOfFiles fpath = FS.getDirectoryContents fpath
答案 0 :(得分:0)
你混淆了for循环类型:
var segmentStore : [Int] = [0,1,2]
//Option A
for index in 0...segmentStore.count-1 {
var element:Int = segmentStore[index];
if element == 0 {
print("Zero");
} else if element == 1 {
print("One");
} else if element == 2 {
print("Two");
}else {
print("Other");
}
}
//Option B
for element: Int in segmentStore {
if element == 0 {
print("Zero");
} else if element == 1 {
print("One");
} else if element == 2 {
print("Two");
}else {
print("Other");
}
}