CoffeeScript 字符串比较 [英] CoffeeScript String Comparison
本文介绍了CoffeeScript 字符串比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 CoffeeScript 中,有没有办法简化以下内容:
In CoffeeScript, is there a way to simplify the following:
if(value === "something" || value === "else" || value === "wow"){}
我试过了:
if value is "something" or "else" or "wow"
但这会产生以下文字输出:
But this produces the literal output of this:
if(value === "something" || "else" || "wow){}
有没有办法检查一个字符串是否是 CoffeeScript 中的多个值(OR 或 AND)之一?
推荐答案
我想你可能想要
if value in ['something', 'else', 'wow']
这篇关于CoffeeScript 字符串比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文