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

Remove redundant code #6

Merged
merged 2 commits into from Feb 6, 2017
Merged

Remove redundant code #6

merged 2 commits into from Feb 6, 2017

Conversation

LarsJK
Copy link
Contributor

@LarsJK LarsJK commented Feb 5, 2017

Removed some redundant code and avoided some force unwrapping.

@sindresorhus sindresorhus changed the title Removes redundant code Remove redundant code Feb 6, 2017
switch arguments.stringAt(0) {
case "--help":
switch arguments.first {
case "--help"?:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially had it like this, but I foolishly used switch arguments[0] which didn't work. Thanks for showing me the correct way.

@@ -8,7 +8,7 @@ struct DarkMode {
}

static func toggle(force: Bool? = nil) {
let val = force != nil ? String(force!) : "not dark mode"
let val = force.map(String.init) ?? "not dark mode"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick!

@sindresorhus
Copy link
Owner

Thank you for the review! :) I really appreciate it. I'm just starting out with Swift, so I'm very keen on learning best practices and what to avoid.


I could also use a review of the Swift part of wulkano/Aperture#26 if you have any interest. No worries if not though.

@sindresorhus sindresorhus merged commit 1dfb9af into sindresorhus:master Feb 6, 2017
@LarsJK
Copy link
Contributor Author

LarsJK commented Feb 6, 2017

Cool 👍 Will have a look at wulkano/Aperture#26 later!

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

Successfully merging this pull request may close these issues.

None yet

2 participants