Xcode 在调用一个拥有返回值的方法,却没有使用该返回值时会提示
Result of call to '' is unused
消除该警告的方法有两种:
- @discardableResult
@discardableResult
public func callSomething() -> Int {
return 0
}
callSomenthing()
- _ = 赋值给 _
public func callSomething() -> Int {
return 0
}
_ = callSomenthing