红宝石 |星期六时间?()函数
saturday?()是 Ruby 中的一个内置方法,如果时间表示星期六,则返回 true,否则返回 false。
Syntax: time.saturday?()
Parameters: The function accepts no parameter
Return Value: It returns true if time represents saturday otherwise false.
示例 1 :
# Ruby code for saturday?() method
# Include Time
require 'time'
# Declaring time
a = Time.new(2000, 12, 23)
# Prints boolean value
puts a.saturday?()
输出:
true
示例 2 :
# Ruby code for saturday?() method
# Include Time
require 'time'
# Declaring time
a = Time.now()
# Prints boolean value
puts a.saturday?()
输出:
false