Ruby '..' aka "2 dot" range operator is inclusive, '...' aka "3 dot" range operator is exclusive
Pontifications
- Ranges constructed using .. run from the beginning to the end inclusively. Those created using … exclude the end value.
- It’s not like C!
variable[0,n]
is the same as ruby’svariable[0..n]
. In rubyvariable[x,n]
means starting at position x, return n elements. Learned this the hard way in production-test-797-redirects.rb
#using ranges. The end position is included with two periods but not with three
array_four[0..1] # => ["a", "b"]
array_four[0...1] # => ["a"]