내가 코드Swift.ArraySlice를 Swift.Array로 변환하는 방법?
if(currentArgument == "")
{
numberOfArgInCurrentFunction -= 1
var lastExp = expressionStack.last!
lastExp["ArgList"] = (lastExp["ArgList"] as! [String]).dropLast()
expressionStack.remove(at: expressionStack.count - 1)
expressionStack.append(lastExp)
if(lastExp.count > 0)
{
let argList:[String:Any] = expressionStack.last!
currentArgument = (argList["ArgList"] as! [String]).last! // ***Error on this line
}
}
아래에서 오류를 얻고있다 '는 Swift.Array'(0x107ef2538)에 유형 'Swift.ArraySlice'(0x107ef4b40)의 값을 캐스팅 할 수 없습니다.
지금 Swift.Array에 Swift.ArraySlice을 변환 할 수있는 방법이나
편집 -
나는 경우 중복를 들어 Swift.ArraySlice
에서 마지막 요소를 얻을 수있는 방법이 알고 싶어요 사용 울부 짖는 코드를 변환 할let slice = argList["ArgList"] as ArraySlice //*** Cannot convert value of type 'Any?' to type 'ArraySlice<_>' in coercion because
let array:[String] = Array(slice)
currentArgument = array.last!
@MartinR 나는 당신이 언급 한 질문 다르다는 것을 설명하기 위해 질문을 편집 한, 만약 내가 잘못 알려 주시기 바랍니다 . –