Skip to content

Instantly share code, notes, and snippets.

@agoiabel
Last active January 14, 2018 19:01
Show Gist options
  • Save agoiabel/617db4b943a984e6f2dea0d2ce2fdfed to your computer and use it in GitHub Desktop.
Save agoiabel/617db4b943a984e6f2dea0d2ce2fdfed to your computer and use it in GitHub Desktop.
enum Day {
case Sunday
case Monday
case Tuesday
case Wednessday
case Thursday
case Friday
case Saturday
}
/** Rewriting the date type function */
func dayType(for day: Day) {
switch day {
case Day.Saturday, Day.Sunday:
return "Weekend"
case Day.Monday, Day.Tuesday, Day.Wednessday, Day.Thursday, Day.Friday
return "Weekday"
}
}
let result1 = dayType(for: Day.Sunday) //will return "Weekend"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment