[swift-evolution] Make non-void functions @warn_unused_result by default

Brent Royal-Gordon brent at architechies.com
Thu Feb 25 15:06:37 CST 2016


> I’d say that the cases where it’s ok to discard the result are when the result is not strictly part of the API, but provided because it could be useful to the caller. An attribute that would naturally describe this could be
> 
> @convenience
> 
> The first example that comes to mind is Dictionary.updateValue. The declaration could then become
> 
>     public mutating func updateValue(value: Value, forKey key: Key) -> @convenience Value?

@convenience reads really, really well, but I'm worried it might get confused with `convenience init`, which means something completely different.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list