红宝石 |范围 exclude_end?函数
exclude_end?()是 Ruby 中的一个内置方法,如果范围不包括其结束值,则返回布尔值 true,否则返回 false。
Syntax: range1.exclude_end?
Parameters: The function accepts no parameter
Return Value: It returns boolean value true if the range excludes its end value, else it returns false.
示例 1 :
# Ruby program for exclude_end?()
# method in Range
# Initialize range
range1 = (0...10)
# Prints the boolean value
puts range1.exclude_end?
输出:
true
示例 2 :
# Ruby program for exclude_end?()
# method in Range
# Initialize range
range1 = (0..10)
# Prints the boolean value
puts range1.exclude_end?
输出:
false