标签: comparator language-design
哪些语言(如果有)支持语法:
a < b < c
其评估为“ a小于b,而b小于c”吗?
a
b
c
为什么这么多语言缺少此功能?
答案 0 :(得分:1)
Python绝对是其中之一! 还有https://til.hashrocket.com/posts/tceb6f2vxe-interval-comparison-in-javascript的Clojure 请参见How do I check whether an int is between the two numbers? =>,这称为“时间间隔比较”。 另请参见Why are interval comparisons (e.g: x < variable < y) not supported in most "mainstream" languages?