您可以使用三元运算符来解决此问题,如果有条件的话,它是一种简单的浓缩语法。语法如下:
(some conditional || or other conditional && required conditional)?someMethodToHandleSuccess:someMethodToHandleFailure
(有条件的)ifTrue:ifFalse是常规语法。希望这会有所帮助!
,
声明您需要匹配的字符串列表,
List<String> mList = ['philippines','dubai','japan'];
然后匹配这样的文本文件字符串,
var myStr = 'dubai';//or your textFieldController.text
if (mList.contains(myStr)) {
print('Welcome from ${myStr}');
} else {
print('Does not match data');
}
或者按照@Rahul Patel的回答,您建议由三元运算符执行
mList.contains(myStr) ? print('Welcome from ${myStr}') : print('Does not match data');
,
尝试一下
#include <stdio.h>
#include <complex.h>
int main(void)
{
double complex z = CMPLX(0.0,-1.0);
printf("z = %.1f%+.1fi\n",creal(z),cimag(z));
return 0;
}
本文链接:https://www.f2er.com/3072439.html