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.
openScad上有类似的东西吗?
list = [2, 3]; if(1 in list){ echo("in"); }else{ echo("not in"); } /* or better: */ list = [2, 3]; isin = 1 in list? 100 : 0;
为此,可以使用内置search()函数并检查结果是否为空:
search()
list = [2, 3, 1]; isin = len(search(1, list)) > 0 ? 100 : 0; echo(isin);