gpt4 book ai didi

javascript - Coffeescript——如何干掉这两条语句

转载 作者:行者123 更新时间:2023-11-30 08:58:51 25 4
gpt4 key购买 nike

我有

alert 'yesb' if "blow" in ["slow", "flow", "blow"] 
alert 'nob' if "blow" not in ["slow", "flow", "blow"]

我宁愿拥有

alert 'yesb' if "blow" in ["slow", "flow", "blow"] else alert "nob"

alert 'yesb' if "blow" in ["slow", "flow", "blow"] else "nob"

alert 'yesx' else alert 'nob' if "xrow" not in ["slow", "flow", "grow"]

alert 'yesx' else 'nob' if "xrow" not in ["slow", "flow", "grow"]

但它们都给出语法错误。

最佳答案

CoffeeScript 的三元 if-then 语法是 if a > b then c else d

所以你要找的是...

alert(if "blow" in ["slow", "flow", "blow"] then 'yesb' else 'nob')

来自 Python 我也遇到了这个问题,因为 Python 的语法是 c if a > b else d

关于javascript - Coffeescript——如何干掉这两条语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11055887/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com