Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Range#eql?

rng.eql?(obj) → true or false

Returns true only if obj is a Range, has equivalent begin and end items (by comparing them with eql?), and has the same exclude_end? setting as the range.

Example
(0..2).eql?(0..2)            #=> true
(0..2).eql?(Range.new(0,2))  #=> true
(0..2).eql?(0...2)           #=> false
See also #entries #exclude_end? #end #first also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1