@discardableResult Swift 5
Silence warning with @discardableResult
If you are not taking return value from any function, complier will give warning. Example with Warning:
Example with @discardableResult:
There are two ways to silence the warning:
• use @discardableResult above the function
• Explicitly discard the return value using _
Note: you have seen warning many times while you use popViewController, it always gives warning because it’s Returns the popped controller and you should use that, if not then you have to silent warning with explicitly discard (_ = ).
_ = navigationController?.popViewController(animated: true)
- If you are expecting result most of the time use _ to silence the warning instead.