【发布时间】:2021-10-30 21:45:04
【问题描述】:
我是 Swift 和编码的新手,所以如果这是一个愚蠢的问题,我很抱歉,但是当我测试我的代码时会出现这个错误。 我的代码是:
class Node {
var value: String
var children = [Node]()
init() {
value = " "
}
}
错误信息说:
main.swift:29:21: error: argument passed to call that takes no arguments
let m0= Node(value:"wash")
这是我的指示:
1. Edit a file named "main.swift"
2. Create a class called Node
3. Do not specify access modifiers
4. Create a property called "value" of type string
5. Create a property called "children" of type array of Nodes
6. Create a default constructor which initializes value to an empty string and children to an empty array
7. Create a constructor which accepts a parameter named value and assigns it to the appropriate property
【问题讨论】:
-
提示:您还没有完成第 7 步。另外,请确保在
let m0行中的=之前有一个空格。