在func
前面加@discardableResult
,可以消除:函数调用后返回值未被使用的警告⚠️
func get() -> Int {
return 10
}
get() // Result of call to 'get()' is unused
@discardableResult
func get() -> Int {
return 10
}
get() // 无警告
或者可以用下划线消除警告
func get() -> Int {
return 10
}
_ = get() // 无警告
网友评论