-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Add Transpose exercise #209
Conversation
Generated by 🚫 danger |
Nice! |
} | ||
} | ||
|
||
return result.map { stripTrailingWhitespace($0) } |
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.
Great use of map! I just wanted to point out that map can also take a function as a parameter. Instead of the trailing closure which is explicitly calling the function you could instead write.
return result.map(stripTrailingWhitespace)
Which is a little cleaner.
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.
good call. That would be an awesome rule to add to Swiftlint. You should suggest it.
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.
In contrast with the Ruby version, the Swift version operates on arrays of
String
s, since the syntax for multi-line strings is rather cumbersome.