Ruby | Array class eql?() operation
Array#eql?() : eql?() is a Array class method which checks if the two arrays are equal or not.
Syntax: Array.eql?()
Parameter: Arrays to compare
Return: true – if the arrays are equal; otherwise false
Code #1 : Example for eql?() method
# Ruby code for eql?() method # declaring arraya = [18, 22, 33, nil, 5, 6] # declaring arrayb = [1, 4, 1, 1, 88, 9] # declaring arrayc = [18, 22, nil, nil, 50, 6] # eql?puts "eql? : #{a.eql?(b)}\n\n" # eql?puts "eql? : #{b.eql?(c)}\n\n" # eql?puts "eql? : #{c.eql?(a)}\n\n" |
Output :
eql? : false eql? : false eql? : false
Code #2 : Example for eql?() method
# Ruby code for eql?() method # declaring arraya = ["abc", "nil", "dog"] # declaring arrayb = ["cow", nil, "dog"] # declaring arrayc = ["cat", nil, nil] # eql?puts "eql? : #{a.eql?(b)}\n\n" # eql?puts "eql? : #{b.eql?(b)}\n\n" # eql?puts "eql? : #{c.eql?(a)}\n\n" |
Output :
eql? : false eql? : true eql? : false

