enum Suit: String {
case spades = "?"
case hearts = "?"
case diamonds = "?"
case clubs = "?"
}
Run Code Online (Sandbox Code Playgroud)
例如,我该怎么做:
for suit in Suit {
// do something with suit
print(suit.rawValue)
}
Run Code Online (Sandbox Code Playgroud)
结果示例:
?
?
?
?
Run Code Online (Sandbox Code Playgroud) 我理解Ruby和Python的收益率.Scala的收益率是多少?
在python中,使用'filter'函数从字符串/列表中删除不需要的项目非常简单,该函数可以与'lambda'函数一起使用.在python中,它很简单:
a = "hello 123 bye-bye !!£$%$%"
b = list(filter(lambda x: x.isalpha(), a))
c = "".join(b)
print(c) #Which would print "hellobyebye"
Run Code Online (Sandbox Code Playgroud)
有没有办法轻松地在swift中复制它,而不先转换为unicode,然后检查unicode值是否在一定范围内?还有,什么'lambda'喜欢快速的东西?