I tried this in my rails console.
2.0.0-p481 :012 > a = 1
=> 1
2.0.0-p481 :013 > z = 26
=> 26
2.0.0-p481 :014 > a..z
=> 1..26
2.0.0-p481 :015 > a...z
=> 1...26
What is the difference between the two?
I tried this in my rails console.
2.0.0-p481 :012 > a = 1
=> 1
2.0.0-p481 :013 > z = 26
=> 26
2.0.0-p481 :014 > a..z
=> 1..26
2.0.0-p481 :015 > a...z
=> 1...26
What is the difference between the two?
A quick check:
(1..3).to_a
# => [1, 2, 3]
(1...3).to_a
# => [1, 2]
Its evident ...
does not include the last value i.e. its the range till n-1
.
Yes, the version with two dots includes the last element, the one with three dots does not:
(1..4).to_a
#=> [1, 2, 3, 4]
(1...4).to_a
#=> [1, 2, 3]