带有链式比较运算符的语言链式、运算符、语言

2023-09-03 12:15:16 作者:久拥深怀

哪些语言(如果有)支持语法:

a < b < c

其中评估为"a小于bb小于c"?

在C语言里是什么意思

为什么这么多语言没有此功能?

推荐答案

巨蟒绝对是其中之一! 并根据https://til.hashrocket.com/posts/tceb6f2vxe-interval-comparison-in-javascript 参见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?