Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use () -> Void for closures with no parameters that return nothing #264

Closed
rayfix opened this issue Feb 7, 2017 · 3 comments
Closed

Use () -> Void for closures with no parameters that return nothing #264

rayfix opened this issue Feb 7, 2017 · 3 comments

Comments

@rayfix
Copy link
Contributor

rayfix commented Feb 7, 2017

This seems to be the standard these days. () -> (), (Void) -> () are not preferred.

@ISosnovik
Copy link

() -> Void is prefered

@JessyCatterwaul
Copy link
Contributor

JessyCatterwaul commented May 18, 2017

I think this rule should follow from two other rules:

  1. Don't use (Void) as a closure input; just use ().
  2. Use Void instead of () for closure outputs.
    Especially with Swift 3's enforcement of parentheses for inputs, I think this adds clarity.

*I do think Void may be better as a tuple element than (). e.g.

let ƒ: (Void, Int) -> Void = {_, int in}

let void: Void = ƒ( (), 1 )
ƒ(void, 2)

I have never felt a desire to use something like this, but that doesn't mean it might not have a use, and it compiles. I like that signature better than this one:

let ƒ: ( (), Int ) -> Void = {_, int in}

@rcritz
Copy link
Contributor

rcritz commented Oct 26, 2018

Added.

@rcritz rcritz closed this as completed Oct 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants