Actionscript是否具有接受数字的内置函数,如果此数字介于2个数字之间,则可以返回布尔值.
例如
3 is between 2 and 6 //returns true 5 is between 10 and 20 //returns false
Michael Aaro.. 5
不,但你可以自己轻松编写代码:
public static function isBetween(x : Number, low: Number, high : Number) : Boolean { return ((x>=low)&&(x<=high)); }
因此,对于您的示例,isBetween(3,2,6)返回true,而isBetween(5,10,20)返回false.也就是说,简单地使用布尔表达式((x> = 2)&&(x <= 6))比isBetween(x,2,6)更具可读性.
不,但你可以自己轻松编写代码:
public static function isBetween(x : Number, low: Number, high : Number) : Boolean { return ((x>=low)&&(x<=high)); }
因此,对于您的示例,isBetween(3,2,6)返回true,而isBetween(5,10,20)返回false.也就是说,简单地使用布尔表达式((x> = 2)&&(x <= 6))比isBetween(x,2,6)更具可读性.