# Ranges and Enumerable problems

**URL:** <https://rubytalk.org/t/ranges-and-enumerable-problems/47478>\
**Category:** ruby-talk\
**Created:** [2 July 2008 14:48 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478 "2008-07-02T14:48:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [2 July 2008 14:48 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/1 "2008-07-02T14:48:52Z")

</div>

Okay so when I play with "!".."~" wrong things happen.

("!".."~").include?("W")  
true

("!.."~").include?(" ")  
false

so far so good, however.

("!".."~").each do |c|  
puts c  
end

!  
"

> **···**
>
> #  
> $  
> %  
> &  
> '  
> (  
> )  
> \*  
> +  
> ,  
> -  
> .  
> /  
> 0  
> 1  
> 2  
> 3  
> 4  
> 5  
> 6  
> 7  
> 8  
> 9  
> =\> "!".."~"
> 
> This is wrong!
> 
> ("!".."~").last  
> =\> "~"
> 
> This is also right.
> 
> It looks to me like a problem with the Enumerable mixin but I guess the  
> question is why?
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [2 July 2008 15:12 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/2 "2008-07-02T15:12:44Z")

</div>

Note this

irb(main):003:0\> "9".succ  
=\> "10"

Try this instead:

(?!..?~).each {|c| p c.chr}

irb(main):008:0\> (?!..?~).include? ?\  
=\> false

Kind regards

robert

> **···**
>
> 2008/7/2 Glen Holcomb \<damnbigman@gmail.com\>:
> 
> > Okay so when I play with "!".."~" wrong things happen.
> > 
> > ("!".."~").include?("W")  
> > true
> > 
> > ("!.."~").include?(" ")  
> > false
> > 
> > so far so good, however.
> > 
> > ("!".."~").each do |c|  
> > puts c  
> > end
> > 
> > !  
> > "  
> > #  
> > $  
> > %  
> > &  
> > '  
> > (  
> > )  
> > \*  
> > +  
> > ,  
> > -  
> > .  
> > /  
> > 0  
> > 1  
> > 2  
> > 3  
> > 4  
> > 5  
> > 6  
> > 7  
> > 8  
> > 9  
> > =\> "!".."~"
> > 
> > This is wrong!
> > 
> > ("!".."~").last  
> > =\> "~"
> > 
> > This is also right.
> > 
> > It looks to me like a problem with the Enumerable mixin but I guess the  
> > question is why?
> 
> --  
> use.inject do |as, often| as.you\_can - without end

---

<div class="post-metadata">

**Author:** ![Sandor\_Szuecs](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Sandor\_Szuecs](https://rubytalk.org/u/Sandor_Szuecs)\
**Post date:** [2 July 2008 17:09 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/3 "2008-07-02T17:09:34Z")

</div>

Hi,

As David wrote before, have a look at the Ascii-Table.

> Okay so when I play with "!".."~" wrong things happen.

irb(main):002:0\> "!"[0]  
=\> 33  
irb(main):003:0\> "~"[0]  
=\> 126

> ("!".."~").include?("W")  
> true

irb(main):001:0\> "W"[0]  
=\> 87

> ("!.."~").include?(" ")  
> false

$ irb  
irb(main):001:0\> " "[0]  
=\> 32

32 is not between 33 and 126, so include?() does it right.

hth. regards, Sandor Szücs

> **···**
>
> On 02.07.2008, at 16:48, Glen Holcomb wrote:  
> --

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [2 July 2008 16:30 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/4 "2008-07-02T16:30:02Z")

</div>

Thanks Robert,

That is interesting. I wonder why it doesn't work as you would expect. The  
range object seems to be correct (at least through limited include? testing)  
however it returns incomplete info whenever you use an Enumerable method or  
a method that appears to use an Enumerable method.

> **···**
>
> On Wed, Jul 2, 2008 at 9:12 AM, Robert Klemme \<shortcutter@googlemail.com\> wrote:
> 
> > 2008/7/2 Glen Holcomb \<damnbigman@gmail.com\>:  
> > \> Okay so when I play with "!".."~" wrong things happen.  
> > \>  
> > \> ("!".."~").include?("W")  
> > \> true  
> > \>  
> > \> ("!.."~").include?(" ")  
> > \> false  
> > \>  
> > \> so far so good, however.  
> > \>  
> > \> ("!".."~").each do |c|  
> > \> puts c  
> > \> end  
> > \>  
> > \> !  
> > \> "  
> > \> #  
> > \> $  
> > \> %  
> > \> &  
> > \> '  
> > \> (  
> > \> )  
> > \> \*  
> > \> +  
> > \> ,  
> > \> -  
> > \> .  
> > \> /  
> > \> 0  
> > \> 1  
> > \> 2  
> > \> 3  
> > \> 4  
> > \> 5  
> > \> 6  
> > \> 7  
> > \> 8  
> > \> 9  
> > \> =\> "!".."~"  
> > \>  
> > \> This is wrong!  
> > \>  
> > \> ("!".."~").last  
> > \> =\> "~"  
> > \>  
> > \> This is also right.  
> > \>  
> > \> It looks to me like a problem with the Enumerable mixin but I guess the  
> > \> question is why?
> > 
> > Note this
> > 
> > irb(main):003:0\> "9".succ  
> > =\> "10"
> > 
> > Try this instead:
> > 
> > (?!..?~).each {|c| p c.chr}
> > 
> > irb(main):008:0\> (?!..?~).include? ?\  
> > =\> false
> > 
> > Kind regards
> > 
> > robert
> > 
> > --  
> > use.inject do |as, often| as.you\_can - without end
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![David\_A\_Black1](https://avatars.discourse-cdn.com/v4/letter/d/bcef8e/32.png) [@David\_A\_Black1](https://rubytalk.org/u/David_A_Black1)\
**Post date:** [2 July 2008 16:34 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/5 "2008-07-02T16:34:26Z")

</div>

Hi --

> > > Okay so when I play with "!".."~" wrong things happen.
> > > 
> > > ("!".."~").include?("W")  
> > > true
> > > 
> > > ("!.."~").include?(" ")  
> > > false
> > > 
> > > so far so good, however.
> > > 
> > > ("!".."~").each do |c|  
> > > puts c  
> > > end
> > > 
> > > !  
> > > "  
> > > #  
> > > $  
> > > %  
> > > &  
> > > '  
> > > (  
> > > )  
> > > \*  
> > > +  
> > > ,  
> > > -  
> > > .  
> > > /  
> > > 0  
> > > 1  
> > > 2  
> > > 3  
> > > 4  
> > > 5  
> > > 6  
> > > 7  
> > > 8  
> > > 9  
> > > =\> "!".."~"
> > > 
> > > This is wrong!
> > > 
> > > ("!".."~").last  
> > > =\> "~"
> > > 
> > > This is also right.
> > > 
> > > It looks to me like a problem with the Enumerable mixin but I guess the  
> > > question is why?
> > 
> > Note this
> > 
> > irb(main):003:0\> "9".succ  
> > =\> "10"
> > 
> > Try this instead:
> > 
> > (?!..?~).each {|c| p c.chr}
> > 
> > irb(main):008:0\> (?!..?~).include? ?\  
> > =\> false
> 
> Thanks Robert,
> 
> That is interesting. I wonder why it doesn't work as you would expect. The  
> range object seems to be correct (at least through limited include? testing)  
> however it returns incomplete info whenever you use an Enumerable method or  
> a method that appears to use an Enumerable method.

In 1.9 you get this:

> > ('!'..'~').to\_a

=\> ["!", "\"", "#", "$", "%", "&", "'", "(", ")", "\*", "+", ",", "-",  
".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";",  
"\<", "=", "\>", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I",  
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",  
"X", "Y", "Z", "[", "\\", "]", "^", "\_", "`", "a", "b", "c", "d", "e",  
"f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",  
"t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~"]

David

> **···**
>
> On Thu, 3 Jul 2008, Glen Holcomb wrote:
> 
> > On Wed, Jul 2, 2008 at 9:12 AM, Robert Klemme \<shortcutter@googlemail.com\> \> wrote:
> > 
> > > 2008/7/2 Glen Holcomb \<damnbigman@gmail.com\>:
> 
> --  
> Rails training from David A. Black and Ruby Power and Light:  
> &nbsp;&nbsp;&nbsp;Intro to Ruby on Rails July 21-24 Edison, NJ  
> &nbsp;&nbsp;&nbsp;Advancing With Rails August 18-21 Edison, NJ  
> See [http://www.rubypal.com](http://www.rubypal.com) for details and updates!

---

<div class="post-metadata">

**Author:** ![Adam\_Shelly](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Adam\_Shelly](https://rubytalk.org/u/Adam_Shelly)\
**Post date:** [2 July 2008 17:13 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/6 "2008-07-02T17:13:41Z")

</div>

It's not Enumerable, it's the Range class's #each method.  
In general, Ranges use the \<=\> operator to test against the first and  
last element to determine inclusion, but they use #succ to generate  
the next element for #each. Some odd behavior arises because  
(s\<=\>s.succ) != -1 for all s.  
I thought that was the whole issue, but it turns out '10' \<=\> '~' is -1.  
It turns out the Range class has special code to deal with Strings -  
it also checks that s.succ.length \< end.length. Without that, your  
example range would enumerate forever.

There has been discussion off and on about changing Range to use some  
new alternate method to #succ which would guarantee 'sane' behavoir,  
but nothing has ever come of it.

-Adam

> **···**
>
> On 7/2/08, Glen Holcomb \<damnbigman@gmail.com\> wrote:
> 
> > That is interesting. I wonder why it doesn't work as you would expect. The  
> > range object seems to be correct (at least through limited include? testing)  
> > however it returns incomplete info whenever you use an Enumerable method or  
> > a method that appears to use an Enumerable method.

---

<div class="post-metadata">

**Author:** ![Glen\_Holcomb](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Glen\_Holcomb](https://rubytalk.org/u/Glen_Holcomb)\
**Post date:** [2 July 2008 16:56 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/7 "2008-07-02T16:56:31Z")

</div>

Thanks David,

That is good to know. Maybe I should upgrade.

> **···**
>
> On Wed, Jul 2, 2008 at 10:34 AM, David A. Black \<dblack@rubypal.com\> wrote:
> 
> > Hi --
> > 
> > On Thu, 3 Jul 2008, Glen Holcomb wrote:
> > 
> > On Wed, Jul 2, 2008 at 9:12 AM, Robert Klemme \<shortcutter@googlemail.com \>\> \> \>\> wrote:
> > 
> > > 2008/7/2 Glen Holcomb \<damnbigman@gmail.com\>:
> > > 
> > > > > Okay so when I play with "!".."~" wrong things happen.
> > > > > 
> > > > > ("!".."~").include?("W")  
> > > > > true
> > > > > 
> > > > > ("!.."~").include?(" ")  
> > > > > false
> > > > > 
> > > > > so far so good, however.
> > > > > 
> > > > > ("!".."~").each do |c|  
> > > > > puts c  
> > > > > end
> > > > > 
> > > > > !  
> > > > > "  
> > > > > #  
> > > > > $  
> > > > > %  
> > > > > &  
> > > > > '  
> > > > > (  
> > > > > )  
> > > > > \*  
> > > > > +  
> > > > > ,  
> > > > > -  
> > > > > .  
> > > > > /  
> > > > > 0  
> > > > > 1  
> > > > > 2  
> > > > > 3  
> > > > > 4  
> > > > > 5  
> > > > > 6  
> > > > > 7  
> > > > > 8  
> > > > > 9  
> > > > > =\> "!".."~"
> > > > > 
> > > > > This is wrong!
> > > > > 
> > > > > ("!".."~").last  
> > > > > =\> "~"
> > > > > 
> > > > > This is also right.
> > > > > 
> > > > > It looks to me like a problem with the Enumerable mixin but I guess the  
> > > > > question is why?
> > > > 
> > > > Note this
> > > > 
> > > > irb(main):003:0\> "9".succ  
> > > > =\> "10"
> > > > 
> > > > Try this instead:
> > > > 
> > > > (?!..?~).each {|c| p c.chr}
> > > > 
> > > > irb(main):008:0\> (?!..?~).include? ?\  
> > > > =\> false
> > > > 
> > > > Thanks Robert,
> > > 
> > > That is interesting. I wonder why it doesn't work as you would expect.  
> > > The  
> > > range object seems to be correct (at least through limited include?  
> > > testing)  
> > > however it returns incomplete info whenever you use an Enumerable method  
> > > or  
> > > a method that appears to use an Enumerable method.
> > 
> > In 1.9 you get this:
> > 
> > ('!'..'~').to\_a
> > 
> > > > 
> > > 
> > > =\> ["!", "\"", "#", "$", "%", "&", "'", "(", ")", "\*", "+", ",", "-",
> > 
> > ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";",  
> > "\<", "=", "\>", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I",  
> > "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",  
> > "X", "Y", "Z", "[", "\\", "]", "^", "\_", "`", "a", "b", "c", "d", "e",  
> > "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",  
> > "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~"]
> > 
> > David
> > 
> > --  
> > Rails training from David A. Black and Ruby Power and Light:  
> > Intro to Ruby on Rails July 21-24 Edison, NJ  
> > Advancing With Rails August 18-21 Edison, NJ  
> > See [http://www.rubypal.com](http://www.rubypal.com) for details and updates!
> 
> --  
> "Hey brother Christian with your high and mighty errand, Your actions speak  
> so loud, I can't hear a word you're saying."
> 
> -Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![Adam\_Shelly](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Adam\_Shelly](https://rubytalk.org/u/Adam_Shelly)\
**Post date:** [2 July 2008 17:17 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/8 "2008-07-02T17:17:31Z")

</div>

Looks like I spoke too soon. Did Range#each change, or did String#succ?

> **···**
>
> On 7/2/08, David A. Black \<dblack@rubypal.com\> wrote:
> 
> > In 1.9 you get this:
> > 
> > \> \> ('!'..'~').to\_a  
> > \> \>  
> > =\> ["!", "\"", "#", "$", "%", "&", "'", "(", ")", "\*", "+", ",", "-",  
> > ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";",  
> > "\<", "=", "\>", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I",  
> > "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",  
> > "X", "Y", "Z", "[", "\\", "]", "^", "\_", "`", "a", "b", "c", "d", "e",  
> > "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",  
> > "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~"]
> 
> On 7/2/08, Adam Shelly \<adam.shelly@gmail.com\> wrote:
> 
> > There has been discussion off and on about changing Range to use some  
> > new alternate method to #succ which would guarantee 'sane' behavoir,  
> > but nothing has ever come of it.

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [2 July 2008 17:40 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/9 "2008-07-02T17:40:53Z")

</div>

\<snip\>

> Some odd behavior arises because  
> (s\<=\>s.succ) != -1 for all s.

Is that so???

I guess you mean there exists an s for which ...

Cheers  
Robert

> **···**
>
> On Wed, Jul 2, 2008 at 7:13 PM, Adam Shelly \<adam.shelly@gmail.com\> wrote:  
> --  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)
> 
> ---  
> AALST (n.) One who changes his name to be further to the front  
> D.Adams; The Meaning of LIFF

---

<div class="post-metadata">

**Author:** ![Adam\_Shelly](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Adam\_Shelly](https://rubytalk.org/u/Adam_Shelly)\
**Post date:** [2 July 2008 17:48 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/10 "2008-07-02T17:48:14Z")

</div>

I'm not sure what you mean

irb(main):027:0\> 1\<=\>1.succ  
=\> -1  
irb(main):028:0\> 'a'\<=\>'a'.succ  
=\> -1  
irb(main):029:0\> 'z'\<=\>'z'.succ  
=\> 1

> **···**
>
> On 7/2/08, Robert Dober \<robert.dober@gmail.com\> wrote:
> 
> > On Wed, Jul 2, 2008 at 7:13 PM, Adam Shelly \<adam.shelly@gmail.com\> wrote:  
> > \<snip\>  
> > \> Some odd behavior arises because  
> > \> (s\<=\>s.succ) != -1 for all s.
> > 
> > Is that so???
> > 
> > I guess you mean there exists an s for which ...

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [2 July 2008 18:27 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/11 "2008-07-02T18:27:01Z")

</div>

He meant

You said: for all s: (s\<=\>s.succ) != -1

He said: there exists at least one s: (s\<=\>s.succ) != -1

It's probably Robert's mathematical training which made him detect that the two statements are not equivalent - and he is absolutely right. 🙂

Kind regards

&nbsp;&nbsp;robert

> **···**
>
> On 02.07.2008 19:48, Adam Shelly wrote:
> 
> > On 7/2/08, Robert Dober \<robert.dober@gmail.com\> wrote:
> > 
> > > On Wed, Jul 2, 2008 at 7:13 PM, Adam Shelly \<adam.shelly@gmail.com\> wrote:  
> > > \<snip\>
> > > 
> > > > Some odd behavior arises because  
> > > > (s\<=\>s.succ) != -1 for all s.
> > > 
> > > Is that so???
> > > 
> > > I guess you mean there exists an s for which ...
> > 
> > I'm not sure what you mean

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [2 July 2008 20:46 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/12 "2008-07-02T20:46:10Z")

</div>

You see Adam it's not my fault I just had bad education;), sorry I  
thought it was just a misstype of yours.

As there exist some s such as ( s \<=\> s.succ) == -1 (most of them by  
the way) your statement  
was wrong, I guess that you got carried away by the not, could easily  
have happened to me.

! for all s: (s\<=\> s.succ) == -1

is true. Do we read each other now?

Cheers  
Robert

> **···**
>
> On Wed, Jul 2, 2008 at 8:27 PM, Robert Klemme \<shortcutter@googlemail.com\> wrote:
> 
> > On 02.07.2008 19:48, Adam Shelly wrote:
> > 
> > > On 7/2/08, Robert Dober \<robert.dober@gmail.com\> wrote:
> > > 
> > > > On Wed, Jul 2, 2008 at 7:13 PM, Adam Shelly \<adam.shelly@gmail.com\> \>\>\> wrote:  
> > > > \<snip\>
> > > > 
> > > > > Some odd behavior arises because  
> > > > > (s\<=\>s.succ) != -1 for all s.
> > > > 
> > > > Is that so???
> > > > 
> > > > I guess you mean there exists an s for which ...
> > > 
> > > I'm not sure what you mean
> > 
> > He meant
> > 
> > You said: for all s: (s\<=\>s.succ) != -1
> > 
> > He said: there exists at least one s: (s\<=\>s.succ) != -1
> > 
> > It's probably Robert's mathematical training which made him detect that the  
> > two statements are not equivalent - and he is absolutely right. 🙂

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [2 July 2008 20:50 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/13 "2008-07-02T20:50:46Z")

</div>

Or another way of saying the same thing (as Robert D.):

&nbsp;&nbsp;&nbsp;!(for all s: (s \<=\>s.succ) == -1)

> **···**
>
> On Wed, Jul 2, 2008 at 2:27 PM, Robert Klemme \<shortcutter@googlemail.com\> wrote:
> 
> > On 02.07.2008 19:48, Adam Shelly wrote:
> > 
> > > On 7/2/08, Robert Dober \<robert.dober@gmail.com\> wrote:
> > > 
> > > > On Wed, Jul 2, 2008 at 7:13 PM, Adam Shelly \<adam.shelly@gmail.com\> \>\>\> wrote:  
> > > > \<snip\>
> > > > 
> > > > > Some odd behavior arises because  
> > > > > (s\<=\>s.succ) != -1 for all s.
> > > > 
> > > > Is that so???
> > > > 
> > > > I guess you mean there exists an s for which ...
> > > > 
> > > > I'm not sure what you mean
> > 
> > He meant
> > 
> > You said: for all s: (s\<=\>s.succ) != -1
> > 
> > He said: there exists at least one s: (s\<=\>s.succ) != -1
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Todd\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Todd\_Benson](https://rubytalk.org/u/Todd_Benson)\
**Post date:** [2 July 2008 22:04 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/14 "2008-07-02T22:04:36Z")

</div>

Well, not really. That gives you no information as to whether such a  
thing does exist. That statement would be true, but not definitive,  
meaning, that it would be true if there is \_no\_ s that satisfies.

I think Robert was going for "at least 1" in his statement.

But, I guess that's just making a mountain out of a mole hill, because  
I think Rick was just pointing out something, and not trying to be  
being rigorously complete.

Todd

> **···**
>
> On Wed, Jul 2, 2008 at 3:50 PM, Rick DeNatale \<rick.denatale@gmail.com\> wrote:
> 
> > &nbsp;&nbsp;!(for all s: (s \<=\>s.succ) == -1)

---

<div class="post-metadata">

**Author:** ![Todd\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Todd\_Benson](https://rubytalk.org/u/Todd_Benson)\
**Post date:** [2 July 2008 22:12 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/15 "2008-07-02T22:12:32Z")

</div>

Okay, that may have been a major faux pas on my part 🙂

Todd

> **···**
>
> On Wed, Jul 2, 2008 at 5:07 PM, Todd Benson \<caduceass@gmail.com\> wrote:
> 
> > On Wed, Jul 2, 2008 at 3:50 PM, Rick DeNatale \<rick.denatale@gmail.com\> wrote:
> > 
> > > &nbsp;&nbsp;!(for all s: (s \<=\>s.succ) == -1)
> > 
> > Well, not really. That gives you no information as to whether such a  
> > thing does exist. That statement would be true, but not definitive,  
> > meaning, that it would be true if there is \_no\_ s that satisfies.
> > 
> > I think Robert was going for "at least 1" in his statement.
> > 
> > But, I guess that's just making a mountain out of a mole hill, because  
> > I think Rick was just pointing out something, and not trying to be  
> > being rigorously complete.

---

<div class="post-metadata">

**Author:** ![Robert\_K1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/robert_k1/32/1830_2.png) [@Robert\_K1](https://rubytalk.org/u/Robert_K1)\
**Post date:** [3 July 2008 09:23 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/16 "2008-07-03T09:23:12Z")

</div>

It is. 🙂 not (for all e: X(e)) \<=\> (there is at least one e: not X(e))

Kind regards

robert

> **···**
>
> 2008/7/3 Todd Benson \<caduceass@gmail.com\>:
> 
> > On Wed, Jul 2, 2008 at 5:07 PM, Todd Benson \<caduceass@gmail.com\> wrote:
> > 
> > > On Wed, Jul 2, 2008 at 3:50 PM, Rick DeNatale \<rick.denatale@gmail.com\> wrote:
> > > 
> > > > &nbsp;&nbsp;!(for all s: (s \<=\>s.succ) == -1)
> > > 
> > > Well, not really. That gives you no information as to whether such a  
> > > thing does exist. That statement would be true, but not definitive,  
> > > meaning, that it would be true if there is \_no\_ s that satisfies.
> > 
> > Okay, that may have been a major faux pas on my part 🙂
> 
> --  
> use.inject do |as, often| as.you\_can - without end

---

<div class="post-metadata">

**Author:** ![Rick\_DeNatale1](https://avatars.discourse-cdn.com/v4/letter/r/bbce88/32.png) [@Rick\_DeNatale1](https://rubytalk.org/u/Rick_DeNatale1)\
**Post date:** [3 July 2008 11:48 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/17 "2008-07-03T11:48:57Z")

</div>

as being related to De Morgan's laws in Boolean algebra, and Wikipedia seems  
to agree [De Morgan's laws - Wikipedia](http://en.wikipedia.org/wiki/De_Morgan%27s_laws#Further_explanation)

> **···**
>
> On Thu, Jul 3, 2008 at 5:23 AM, Robert Klemme \<shortcutter@googlemail.com\> wrote:
> 
> > 2008/7/3 Todd Benson \<caduceass@gmail.com\>:  
> > \> On Wed, Jul 2, 2008 at 5:07 PM, Todd Benson \<caduceass@gmail.com\> wrote:  
> > \>\> On Wed, Jul 2, 2008 at 3:50 PM, Rick DeNatale \<rick.denatale@gmail.com\> \> wrote:  
> > \>\>\> !(for all s: (s \<=\>s.succ) == -1)  
> > \>\>  
> > \>\> Well, not really. That gives you no information as to whether such a  
> > \>\> thing does exist. That statement would be true, but not definitive,  
> > \>\> meaning, that it would be true if there is \_no\_ s that satisfies.  
> > \>  
> > \> Okay, that may have been a major faux pas on my part 🙂
> > 
> > It is. 🙂 not (for all e: X(e)) \<=\> (there is at least one e: not X(e))
> > 
> > Yep, I remember getting A's in my logic courses. I vaguely remembered this
> 
> --  
> Rick DeNatale
> 
> My blog on Ruby  
> [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![Adam\_Shelly](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Adam\_Shelly](https://rubytalk.org/u/Adam_Shelly)\
**Post date:** [3 July 2008 17:17 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/18 "2008-07-03T17:17:44Z")

</div>

Wow, I seem to have started quite a tangent. That's exactly what I  
was thinking, but when I translated my thoughts into pseudo-ruby, I  
put the ! in the wrong place for boolean logic, which I wasn't even  
considering.

I never did get an answer to my question about v1.9 - it's probably  
time for me to install it - but until I do:  
did String#succ change? Does '9'.succ return ':' now?  
Is the above statement - which was true in 1.85 - no longer true in 1.9?

-Adam

> **···**
>
> On 7/3/08, Rick DeNatale \<rick.denatale@gmail.com\> wrote:
> 
> > On Thu, Jul 3, 2008 at 5:23 AM, Robert Klemme \<shortcutter@googlemail.com\> \> wrote:
> > 
> > \> 2008/7/3 Todd Benson \<caduceass@gmail.com\>:  
> > \> \> On Wed, Jul 2, 2008 at 5:07 PM, Todd Benson \<caduceass@gmail.com\> wrote:  
> > \> \>\> On Wed, Jul 2, 2008 at 3:50 PM, Rick DeNatale \<rick.denatale@gmail.com\> \> \> wrote:  
> > \> \>\>\> !(for all s: (s \<=\>s.succ) == -1)  
> > \> \>\>

---

<div class="post-metadata">

**Author:** ![Todd\_Benson](https://avatars.discourse-cdn.com/v4/letter/t/34f0e0/32.png) [@Todd\_Benson](https://rubytalk.org/u/Todd_Benson)\
**Post date:** [5 July 2008 00:29 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/19 "2008-07-05T00:29:29Z")

</div>

Okay, you made your point, but you don't have to rub it in... (crosses  
arms and says "hmppph" [picture a little girl here] 🙂

I don't know why, but when I first looked at it, I had a gut feeling  
there was something wrong with Rick's statement. Then, I realized my  
mistake. Darn it!

Todd

> **···**
>
> On Thu, Jul 3, 2008 at 6:48 AM, Rick DeNatale \<rick.denatale@gmail.com\> wrote:
> 
> > On Thu, Jul 3, 2008 at 5:23 AM, Robert Klemme \<shortcutter@googlemail.com\> \> wrote:
> > 
> > > \> Okay, that may have been a major faux pas on my part 🙂
> > > 
> > > It is. 🙂 not (for all e: X(e)) \<=\> (there is at least one e: not X(e))
> > > 
> > > Yep, I remember getting A's in my logic courses. I vaguely remembered this
> > 
> > as being related to De Morgan's laws in Boolean algebra, and Wikipedia seems  
> > to agree [De Morgan's laws - Wikipedia](http://en.wikipedia.org/wiki/De_Morgan%27s_laws#Further_explanation)
> > 
> > --  
> > Rick DeNatale

---

<div class="post-metadata">

**Author:** ![Forum](https://avatars.discourse-cdn.com/v4/letter/f/43a26b/32.png) [@Forum](https://rubytalk.org/u/Forum)\
**Post date:** [3 July 2008 18:37 UTC](https://rubytalk.org/t/ranges-and-enumerable-problems/47478/20 "2008-07-03T18:37:56Z")

</div>

Adam my apologies, instead of logic nitpicking, which was fun of  
course, I could have provided an answer to the original question too  
;).  
But you will not like it ☹

robert@roma:~ 20:27:45  
437/7 \> ruby1.9 -v -e 'p "9".succ'  
ruby 1.9.0 (2007-12-25 revision 14709) [i486-linux]  
"10"

Cheers  
Robert

> **···**
>
> --  
> [http://ruby-smalltalk.blogspot.com/](http://ruby-smalltalk.blogspot.com/)
> 
> ---  
> AALST (n.) One who changes his name to be further to the front  
> D.Adams; The Meaning of LIFF

[Next page](https://rubytalk.org/t/ranges-and-enumerable-problems/47478.md?page=2)
