From: "trans. (T. Onoma)" Date: 2004-10-06T11:18:50+09:00 Subject: Re: Range behavior (Re: [RCR] New [] Semantics) On Tuesday 05 October 2004 08:19 pm, Yukihiro Matsumoto wrote: > Hi, > > I changed the subject. > > In message "Re: [RCR] New [] Semantics" > > on Tue, 5 Oct 2004 18:19:09 +0900, "trans. (T. Onoma)" writes: > |I occurs to me that the angry villagers might be confused. The example of > | the never ending > | > | (0..(10.0/0)).member?(4) > | > |comes to mind. Why would this be an infinite loop? > > 'member?' should have terminated iteration as soon as it find the > value. I will fix. > > Range serves as both continuous and discrete interval of values. > 'member?' treat it as discrete, whereas 'include?' treat it as > continuous. irb(main):001:0> a = 0..2 => 0..2 irb(main):002:0> a.include?(1) => true irb(main):003:0> a.include?(1.5) => true irb(main):004:0> a = a.to_a => [0, 1, 2] irb(main):005:0> a.include?(1) => true irb(main):006:0> a.include?(1.5) => false :( T.