This project includes solutions to the challenges.
- Create a
String
extension that adds awithPrefix()
method. If the string already contains the prefix it should return itself; if it doesn’t contain the prefix, it should return itself with the prefix added. For example:"pet".withPrefix("car")
should return “carpet”. - Create a
String
extension that adds anisNumeric
property that returns true if the string holds any sort of number. Tip: creating aDouble
from aString
is a failable initializer. - Create a
String
extension that adds alines
property that returns an array of all the lines in a string. So, “this\nis\na\ntest” should return an array with four elements.
No screenshots provided (since it is a playground).