Type Safely

Type Safely

Use @discardableResult To Choose Whether To Use Return Values

Daily Coding Tip 027

Type Safely's avatar
Type Safely
Jan 14, 2021
∙ Paid
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…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture