Type Safely

Type Safely

Share this post

Type Safely
Type Safely
Use @discardableResult To Choose Whether To Use Return Values

Use @discardableResult To Choose Whether To Use Return Values

Daily Coding Tip 027

Type Safely's avatar
Type Safely
Jan 14, 2021
∙ Paid
1

Share this post

Type Safely
Type Safely
Use @discardableResult To Choose Whether To Use Return Values
Share
Image by Karl Egger from Pixabay

If you want to call a function that returns a value called addValues(), you’ll notice that it gives you a warning that says “Result of call to addValues() is unused.” You may not always want to use the result, so there’s an easy way to suppress this warning.

Adding @discardableResult before your function declaration gives…

Keep reading with a 7-day free trial

Subscribe to Type Safely to keep reading this post and get 7 days of free access to the full post archives.

Already a paid subscriber? Sign in
© 2025 Type Safely
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share