[swift-evolution] Disambiguate Return Type With Void

Andrew Bennett cacoyi at gmail.com
Mon Mar 28 03:21:57 CDT 2016

Swift can resolve functions based on the return type. However, when the
result is unused a single function often can't be resolved without
explicitly specifying the type.

func example() { ... }
func example() -> Int { ... }

example() as Void
example() as Int

This proposal disambiguates some cases:

   - Preferring functions with a *Void* return type when the result *is*
   - Preferring functions with a *non-Void* type when the result *is not*

These example will be unambiguous:

example() // will prefer a `Void` function
let x = example() // will prefer a non-`Void` function

You can read the full latest version of the proposal here:


This is the original version
the proposal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160328/9e3a73a4/attachment.html>

More information about the swift-evolution mailing list