From: matz@... (Yukihiro Matsumoto) Date: 1999-07-09T15:04:24+09:00 Subject: [ruby-talk:00441] Re: Now another totally different ;-) Hi, In message "[ruby-talk:00440] Now another totally different ;-)" on 99/07/09, Clemens Hintze writes: | |1. I think that the mix-in module Enumeration, could also offer a |method `[]', as that is easy possible to realize via `each'. You CAN define it for Enumerable, but I think we don't have to define it. There are some classes which can be enumerable but not indexable, for example, Mathematical Set (non-ordered set), and Hash are such classes. In addition, Hash has non number indexing method [], which may be the source of confusion if we define Enumerable#[]. |2. The operators `..' and `...' cannot be overwritten! Yes, it's part of the syntax. Because dots operators appears at condition, they work differently. In reference manual: If range expression appears in conditional expression, it gives false until left hand side returns true, it stays true until right hand side is true. .. acts like awk, ... acts like sed. It is possible to call ../... method outside of condition. It makes behavior of the operators bit complex, so we need to discuss about it. I'm not sure stepping forward (i.e. make ../... method call) is suitable or not. Personally, I don't like mapping operators to method very much. But it is needed to make Ruby handy. I prefer generic function style as in CLOS for mathematical operators, where operands are conceptually equal. But that is too much for the language, enough to abandon to include in Ruby. matz.