Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Show Menu and Dock Icon whilst interacting #121
Show Menu and Dock Icon whilst interacting #121
Changes from all commits
5fff6a9
9b84b47
19fc8ce
163f02a
c534d69
4395c31
aedd6ff
4fd457f
2b49302
5131185
be37508
e4aad75
b7d56bf
c7bc4aa
1c8e5a5
dbc0ba7
8d95f52
a2f4a32
52f53a3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep shuddering a little knowing that some code running on my machine is so devoted to not having early returns. (And apparently the ternary operator too.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to suggest a change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, in this case I'd write it in one line:
return NSApp.setActivationPolicy(state ? NSApplication.ActivationPolicy.regular : NSApplication.ActivationPolicy.accessory)
Dunno if Swift's
[.thing]
syntax allows to remove the duplication ofNSApplication.ActivationPolicy
too.Generally, I'm a big fan of early
return
s, especially for exceptional inputs that cause functions to not do usual stuff. They're pretty much saying “input wrong? no can do” right at the start, and as a bonus avoid extra nesting. Also they work smoothly with more-functional style, which is very nice, in my book.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swift warning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, apparently it's Swift saying to drop
return
altogether in one-liner functions. Didn't know about that. Seems they're bent even further in the functional direction than older mainstream languages.