What is the difference between .eql? and == in Ruby ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between .eql? and == in Ruby ?

20th Apr 2017, 4:41 AM
Ruby
2 Answers
0
== operator is used to compare the values of the operands but the .eql? is used to compare the data types.
20th Apr 2017, 4:42 AM
Ruby
0
== is used to compare the values of the operands but the .eql? is used to compare the data types. For example, 5==5.0 but 5.eql?5.0 is not true
31st Aug 2017, 6:20 AM
Z E
Z E - avatar