红宝石 |整数 <= 方法
<=是 Ruby 中的一个内置方法,如果数字小于或等于给定数字,则返回 true,否则返回 false。
Syntax: num1 <= num2
Parameters: The function accepts no parameter.
Return Value: It returns true if the number is less than or equal to the given number, else it returns false.
示例 1 :
# Ruby program for <= method in Integer
# Initialize numbers
num1 = 3
num2 = 3
# Prints equal to or not
print num1 <= num2
输出:
true
示例 2 :
# Ruby program for <= method in Integer
# Initialize numbers
num1 = 6
num2 = 5
# Prints equal to or not
print num1 <= num2
输出:
false