Swift编译器错误:字符串连接上的“表达式太复杂”
我觉得这比任何事都更有趣。我修好了,但我想知道原因。这是错误:DataManager.swift:51:90: Expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
。为什么抱怨?这似乎是最简单的表达方式之一。
编译器指向该columns + ");";
部分
func tableName() -> String { return("users"); } func createTableStatement(schema: [String]) -> String { var schema = schema; schema.append("id string"); schema.append("created integer"); schema.append("updated integer"); schema.append("model blob"); var columns: String = ",".join(schema); var statement = "create table if not exists " + self.tableName() + "(" + columns + ");"; return(statement);}
修复是:
var statement = "create table if not exists " + self.tableName();statement += "(" + columns + ");";
这也有效(通过@efischency),但我不喜欢它,因为我觉得(
迷路了:
var statement = "create table if not exists \(self.tableName()) (\(columns))"
慕无忌1623718
qq_花开花谢_0