We can check if today is Friday in Ruby when you call the
friday? method on a time object. It returns a Boolean value.
true is returned if today is Friday. Otherwise,
false is returned.
t_o: this is the time object. This time object can be created in many ways.
The value returned is a Boolean value. It returns
true if the day or the time represents Friday.
# create time objects t1 = Time.now t2 = Time.new(2020) t3 = Time.new(1987, 12, 18) # friday December, 1987 # check if Friday # and print result puts t1.friday? puts t2.friday? puts t3.friday?
View all Courses