Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialFlorian Groussin
4,563 PointsHi
hello this code is obviously not working could some one could tell what i'am not doing right then permit me to correct myself?
Thank you in advance have a nice day & week end.
Florian
extension String {
var add: Int {
return self + Int if {
self = Int }
else {
return nil }
}
}
1 Answer
Alexander Karan
Courses Plus Student 15,220 PointsSo in this challenge you need to add a function and convert the string to a int. The function need to return an optional because the string might not be a number. You can use int(self) to convert
extension String {
func add(valueToAdd: Int) -> Int? {
if let currentString = Int(self) {
return currentString + valueToAdd
} else { return nil }
}
}
Lukas Muller
7,347 PointsLukas Muller
7,347 PointsCould you describe what you are supposed to do?