From: Henrik Horneber Date: 2004-09-30T22:58:26+09:00 Subject: Re: Range syntax theory Hi! From an intellectual point I sort of understand the '..' and '..' notation. What distracts me most, is the visual difference ... that the visually longer three dot form contains fewer elements than the shorter two dot form. (1..5).to_a =>[1,2,3,4,5] (1...5).to_a =>[1,2,3,4] Henrik Gavin Kistner wrote: > On Sep 30, 2004, at 7:30 AM, Zach Dennis wrote: > >> How range operators work seems sort of backwards to me. It would >> appear as if the "..." (three dots) would be the inclusive one, >> including the last value and the ".." (two dots) would be exclusive >> and exclude the last value. > > > I was thinking this exact same thing in the shower yesterday morning. > > > I've tried to memorize what _why said about them, to remember: > >> Think of it as an accordion which has been squeezed down for carrying. >> (Sure, you can build a great sense of self-worth by carrying around an >> unfolded accordion, but sometimes a person needs to wallow in >> self-doubt, carefully concealing the squeeze-box.) The parentheses are >> the handles on the sides of a smaller, handheld accordion. The dots >> are the chain, keeping the folds tightly closed. >> >> Normally, only two dots are used. If a third dot is used, the last >> value in the range is excluded. >> >> (0...5) represents the numbers 0 through 4. >> >> When you see that third dot, imagine opening the accordion slightly. >> Just enough to let one note from its chamber. The note is that end >> value. We�ll let the sky eat it. > > > Source: http://poignantguide.net/ruby/chapter-3.html#section2 > > >