以下代码用于测试字符串相等性,并按预期返回False ("A"与"B"不同):
var rule = new Tuple<string, Func<string, string, bool>, stringstring.EndsWith函数而不是string.Equals。下面的代码在Visual Studio中无法编译并发出Cannot convert from 'method gr
但是,当我试图将其放入项目中时,Xcode会给出以下警告:Treating a forced downcast to 'String' as optional will never produce 'nilto perform a conditional downcast to 'String',这是完全没有意义的。但是,它确实编译时没有警告/错误,这似乎很奇怪,因为它为非可选类型的String分配了一个可选值。
使用类型强制转换操作符的条件形式(as?)当你不确定沮丧是否会成功的