On 2002.05.18, Holden Glova <dsafari / xtra.co.nz> wrote:
> > What about a[1...1]=2
> >
> > Seems to work for me...
> 
> I'll be damned. How this works doesn't make any sense to me. To me that 
> reads; from the 1 position upto but excluding the 1 position, put a value (2 
> in this case). 
> 
> The same can be done with something like array[1,0]=2 as was pointed out by 
> Rennex on IRC #ruby-lang. To me that reads; from the 1 position with a length 
> of 0 assign the value. I'm almost reading this as a 1/2 element index - from 
> a readability point of view to me it just doesn't make sense.
> 
> Can anyone help me understand it from a readability POV? Some on irc have 
> tried to explain it in implementation terms but when I'm coding in Ruby I'm 
> not thinking about how it is understood in Ruby, more about how it reads in 
> Ruby. Any help is welcomed. Thank you.

IMHO, it's a bug as it breaks the contract for Range:

(1...1).size            # => 0
(1...1).begin           # => 1
(1...1).end             # => 1   <-- should be 0!

-- Dossy

-- 
Dossy Shiobara                       mail: dossy / panoptic.com 
Panoptic Computer Network             web: http://www.panoptic.com/ 
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)