Ruby Ranges first and last release

I stumbled upon strange behavior while playing with the ranges expected:

(1...1).count
# => 0 
(1...1).first(1)
# => [] 
(1...1).last(1)
# => []
(1...1).to_a
# => [] 

but

(1...1).first
# => 1
(1...1).last
# => 1

Am I missing something or is this intentional behavior?

+4
source share

Source: https://habr.com/ru/post/1609622/


All Articles