I need to design a String type extension that represents a day of the week and returns the corresponding number starting with Sunday = 1 and ending with Saturday = 7
for example sunday = 1 , monday = 2 , tuesday = 3 , wednesday = 4 ,thurday = 5 , friday = 6, saturday = 7
Here is one idea that i have, but i don't know how to put the Int for the value of the day of the week:
extension String{
var sunday: String {return self}
var monday: String {return self}
var tuesday:String {return self}
var wednesday: String {return self}
var thursday: String {return self}
var friday: String {return self}
var saturday: String {return self}
}
Another idea is this but i don't know how to return the number or if its value to add the days of the week below to daysW :
extension String{
var daysW:String{
return self
}
func number() -> Int{
return self
}
}
.daysW
.number()
Please can somebody help me , i'm new with Swift and it's confusing