let words = ["ss","aa","bb","ddd"]
let tweet = "this is an example tweet larking about swift sad"
let valid = !words.filter({tweet.containsString($0)}).isEmpty
print(valid)
print(words.contains(tweet.containsString))
print(tweet.characters.split(" ").lazy.map(String.init).contains(Set(words).contains))
10个惊艳的Swift单行代码:
http://www.cocoachina.com/swift/20160429/16051.html
时间: 2024-10-12 11:18:34