import UIKit
let weekDays:[String] = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"SUNDAY",
"MONDAY",
"TUESDAY",
"WEDNESDAY",
"THURSDAY",
"FRIDAY",
"SATURDAY"
]
var myDays = weekDays.filter({ $0.hasSuffix("nday") })
print(myDays)
//Result = ["Sunday", "Monday"]
myDays = weekDays.filter({$0.caseInsensitiveCompare("tuesday") == .orderedSame})
print(myDays)
//Result = ["Tuesday", "TUESDAY"]
myDays = weekDays.filter({$0.lowercased().contains("sday")})
print(myDays)
//Result = ["Tuesday", "Wednesday", "Thursday", "TUESDAY", "WEDNESDAY", "THURSDAY"]
All one can think and do in a short time is to think what one already knows and to do as one has always done!
No comments:
Post a Comment
NO JUNK, Please try to keep this clean and related to the topic at hand.
Comments are for users to ask questions, collaborate or improve on existing.