Created
February 18, 2015 08:04
-
-
Save deangerber/93d76b839fff589e922d to your computer and use it in GitHub Desktop.
Feedback for https://github.com/StevenMcD/swift_katas to be pasted into Xcode playground.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Better class name. Removed unneeded ; from code lines. | |
class StringCalculator { | |
// Made class level method | |
// Removed unneeded () around return value | |
class func add(numbers: String) -> Int { | |
// Removed unneeded () around if condition | |
if numbers.isEmpty { | |
return 0 | |
} | |
// No need to cast. String has method to create int value. Returns optional so forcing unwrap. Not the nicest but simplest. | |
return numbers.toInt()! | |
} | |
} | |
// Not sure how to call test from playground so simple value checking. | |
StringCalculator.add("") == 0 | |
StringCalculator.add("1") == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment