Skip to content
Related Articles

Related Articles

Ruby | Time eql?() function

View Discussion
Improve Article
Save Article
  • Last Updated : 07 Jan, 2020
View Discussion
Improve Article
Save Article

The eql?() is an inbuilt method in Ruby returns true if time and other time are both time objects with the same seconds and fractional seconds otherwise false

Syntax: time.eql?()

Parameters: The function accepts no parameter

Return Value: It returns true if time and other time are both time objects with the same seconds and fractional seconds otherwise false

Example 1:




# Ruby code for eql?() method
  
# Include Time
require 'time'
  
# Declaring time 
a = Time.new(2000, 12, 23, 9, 3, 3.0)
b = Time.new(2000, 12, 23, 9, 3, 3.0)
  
# Prints boolean value
puts a.eql?(b)

Output:

true

Example 2:




# Ruby code for eql?() method
  
# Include Time
require 'time'
  
# Declaring time 
a = Time.new(2000, 12, 23, 9, 3, 3.0)
b = Time.new(2000, 12, 23, 9, 3, 4.0)
  
# Prints boolean value
puts a.eql?(b)

Output:

false
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!