Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
代替 :
if(x >= 0 || x <= MAX)
我想写:
if(x in [0..MAX])
但它失败了。Dart 提供类似的东西吗?
到目前为止,核心 dart 中没有序列生成器。但即使它存在,这也是一个坏主意。该if(x in [0..MAX])检查必须将 x 与 中的每个元素进行比较[0..MAX],而 theif(x >= 0 || x <= MAX)只是两个比较。
[0..MAX]