Whaaaaat?

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.

Can someone explain this nonsense?

t.

···

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Tom Cloyd wrote:

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.

Can someone explain this nonsense?

t.

Sorry - inadequate details: running ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]

t.

···

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.

Nope.

Can someone explain this nonsense?

Yep. You've got an array with a single member... the range 0..5.

I think what you meant is:

  (0..5).include? 0
  => true

:slight_smile:

Ben

···

On Tue, May 12, 2009 at 4:39 PM, Tom Cloyd <tomcloyd@comcast.net> wrote:

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.

Can someone explain this nonsense?

Same reason as this:

["hello world"].include? "hell"

=> false

We're asking whether the array contains a particular
object.

Regards,

bill

···

From: "Tom Cloyd" <tomcloyd@comcast.net>

[0..5] is an array with a single element, a Range object representing
the range from 0 to 5.

(0..5).to_a gives you [0,1,2,3,4,5] which is probably what you assumed
you got with [0..5]

(0..5).include?(0) will work, as well, because ranges support the
include? method.

Kirk Haines

···

On Tue, May 12, 2009 at 5:39 PM, Tom Cloyd <tomcloyd@comcast.net> wrote:

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.

Can someone explain this nonsense?

Ben Bleything wrote:

  

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.
    
Nope.

Can someone explain this nonsense?
    
Yep. You've got an array with a single member... the range 0..5.

I think what you meant is:

  (0..5).include? 0
  => true

:slight_smile:

Ben

Well, nuts.

This clarifies it a bit:

irb(main):009:0> (1..10).class
=> Range
irb(main):010:0> [1..10].class
=> Array
irb(main):011:0>

Why can't ruby just do what I mean, rather than what I say? Is that asking too much? (heh heh)

Thanks for the clarifications. This list has not equal for speedy answers (usually).

t.

···

On Tue, May 12, 2009 at 4:39 PM, Tom Cloyd <tomcloyd@comcast.net> wrote:

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Kirk Haines wrote:

···

On Tue, May 12, 2009 at 5:39 PM, Tom Cloyd <tomcloyd@comcast.net> wrote:
  

p [0..5].include? 0
false
p [0..5].member? 0
false

This is nuts. The world is flat, evidently.

Can someone explain this nonsense?
    
[0..5] is an array with a single element, a Range object representing
the range from 0 to 5.

(0..5).to_a gives you [0,1,2,3,4,5] which is probably what you assumed
you got with [0..5]

(0..5).include?(0) will work, as well, because ranges support the
include? method.

Kirk Haines

Thanks, Kirk. That's the best answer yet. Very helpful.

t.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But it does, I am sure you just forgot the *, right?
[*0..5].include? 42
--> false
Cheers
Robert

···

On Wed, May 13, 2009 at 1:57 AM, Tom Cloyd <tomcloyd@comcast.net> wrote:

Why can't ruby just do what I mean, rather than what I say? Is that asking
too much? (heh heh)

Robert Dober wrote:

···

On Wed, May 13, 2009 at 1:57 AM, Tom Cloyd <tomcloyd@comcast.net> wrote:
  

Why can't ruby just do what I mean, rather than what I say? Is that asking
too much? (heh heh)
    

But it does, I am sure you just forgot the *, right?
[*0..5].include? 42
--> false
Cheers
Robert

Robert,

Interesting, but obscure. I just did a quick dig into Thomas (Pickaxe, 3rd ed.), to try to figure out what [*1..5] does, and I still don't get it. Can you explain?

t.

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The"pre-appending" (yes I'm aware that's not a word or proper
conjuction) _star_ flattens arrays/ranges. Well, not exactly; it
allows you to use a "list" of things. Some people avoid it because of
a supposed performance issue. Pick your battle, I guess.

It happens to be useful to me. I really hope they don't get rid of
that nomenclature (much like getting rid of #inject; if so, goodbye
Ruby for me).

Todd

···

On Tue, May 12, 2009 at 8:34 PM, Tom Cloyd <tomcloyd@comcast.net> wrote:

Robert Dober wrote:

On Wed, May 13, 2009 at 1:57 AM, Tom Cloyd <tomcloyd@comcast.net> wrote:

Why can't ruby just do what I mean, rather than what I say? Is that
asking
too much? (heh heh)

But it does, I am sure you just forgot the *, right?
[*0..5].include? 42
--> false
Cheers
Robert

Robert,

Interesting, but obscure. I just did a quick dig into Thomas (Pickaxe, 3rd
ed.), to try to figure out what [*1..5] does, and I still don't get it. Can
you explain?

I do not believe I have ever heard of that intention, if they get rid
of *0..3 than there is nothing one can do, if they get rid of inject
we will just reimplement it :wink:
Robert

···

On Wed, May 13, 2009 at 4:02 AM, Todd Benson <caduceass@gmail.com> wrote:

On Tue, May 12, 2009 at 8:34 PM, Tom Cloyd <tomcloyd@comcast.net> wrote:

Robert Dober wrote:

On Wed, May 13, 2009 at 1:57 AM, Tom Cloyd <tomcloyd@comcast.net> wrote:

Why can't ruby just do what I mean, rather than what I say? Is that
asking
too much? (heh heh)

But it does, I am sure you just forgot the *, right?
[*0..5].include? 42
--> false
Cheers
Robert

Robert,

Interesting, but obscure. I just did a quick dig into Thomas (Pickaxe, 3rd
ed.), to try to figure out what [*1..5] does, and I still don't get it. Can
you explain?

The"pre-appending" (yes I'm aware that's not a word or proper
conjuction) _star_ flattens arrays/ranges. Well, not exactly; it
allows you to use a "list" of things. Some people avoid it because of
a supposed performance issue. Pick your battle, I guess.

It happens to be useful to me. I really hope they don't get rid of
that nomenclature (much like getting rid of #inject; if so, goodbye
Ruby for me).

--
Si tu veux construire un bateau ...
Ne rassemble pas des hommes pour aller chercher du bois, préparer des
outils, répartir les tâches, alléger le travail… mais enseigne aux
gens la nostalgie de l’infini de la mer.

If you want to build a ship, don’t herd people together to collect
wood and don’t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.

--
Antoine de Saint-Exupéry

I'm pretty sure the word you want is either "prefixing" or, if you like
the hypercorrect neologism, "prepending".

···

On Wed, May 13, 2009 at 11:02:45AM +0900, Todd Benson wrote:

The"pre-appending" (yes I'm aware that's not a word or proper
conjuction) _star_ flattens arrays/ranges. Well, not exactly; it

--
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
Quoth Edward Murphy, Jr. (Murphy's Law): "If there's more than one way
to do a job and one of those ways will end in disaster, then someone
will do it that way."

Todd Benson wrote:

It happens to be useful to me. I really hope they don't get rid of
that nomenclature (much like getting rid of #inject; if so, goodbye
Ruby for me).

I never heard any proposal to get rid of Enumberable#inject, and I don't
think it's something you need to worry about. Ruby 1.9 has been adding
hundreds of new methods, not taking them away.

···

--
Posted via http://www.ruby-forum.com/\.

Chad Perrin wrote:

···

On Wed, May 13, 2009 at 11:02:45AM +0900, Todd Benson wrote:

The"pre-appending" (yes I'm aware that's not a word or proper
conjuction) _star_ flattens arrays/ranges. Well, not exactly; it

I'm pretty sure the word you want is either "prefixing" or, if you like
the hypercorrect neologism, "prepending".

Hrm. I had always thought of 'prepend' as a commonplace, dictionary
word, and was about to point out that it was such, until I accidentally
looked it. Neologismtastic!
--
Posted via http://www.ruby-forum.com/\.

Brian Candler wrote:

Todd Benson wrote:

It happens to be useful to me. I really hope they don't get rid of
that nomenclature (much like getting rid of #inject; if so, goodbye
Ruby for me).

I never heard any proposal to get rid of Enumberable#inject, and I don't
think it's something you need to worry about. Ruby 1.9 has been adding
hundreds of new methods, not taking them away.

1.9.1 adds Enumerable#reduce as synonym (which makes more sense to me)
and
still retains inject

···

--
Posted via http://www.ruby-forum.com/\.

Adam Gardner wrote:

Chad Perrin wrote:
  

The"pre-appending" (yes I'm aware that's not a word or proper
conjuction) _star_ flattens arrays/ranges. Well, not exactly; it
      

I'm pretty sure the word you want is either "prefixing" or, if you like
the hypercorrect neologism, "prepending".
    
Hrm. I had always thought of 'prepend' as a commonplace, dictionary word, and was about to point out that it was such, until I accidentally looked it. Neologismtastic!
  

Actually, this is all unnecessary. In linguistics, for eons, we have spoken of prefix and suffix usage, So, this is a prefix asterisk, as in "...the meaning of this prefix asterisk is blah blah...". That says it just fine, with no new language. Travel light.

t.

···

On Wed, May 13, 2009 at 11:02:45AM +0900, Todd Benson wrote:

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Cloyd, MS MA, LMHC - Private practice Psychotherapist
Bellingham, Washington, U.S.A: (360) 920-1226
<< tc@tomcloyd.com >> (email)
<< TomCloyd.com >> (website) << sleightmind.wordpress.com >> (mental health weblog)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is one of #reduce or #inject deprecated in 1.9.1?

Regards,

Jeremy Henty

···

On 2009-05-14, Jeff Moore <jcmoore@pressenter.com> wrote:

1.9.1 adds Enumerable#reduce as synonym (which makes more sense to
me) and still retains inject

Don't think so.

Actually IMHO which makes more sense is situational. To me reduce
makes sense when the optional initial argument is not used, and inject
makes more sense when it is:

collection.reduce {|memo, element| ...}
vs
collection.inject(initial_value) {|memo, element| ...}

Several of the Enumerable method names were pretty obviously inspired
by the Smalltalk collection hierarcy, select, detect, reject, and
inject among them. The Smalltalk method is inject:info: which makes
the meaning of inject a bit clearer, in Smalltalk you would write the
second example as:

  collection inject: initialValue into: [memo, element| ...]

You are injecting the initialValue into the sequence given to the block.

And there are other instances of long-standing aliases like find for detect.

Personally I think it's good to have such synonyms, they make it
easier to be express subtleties just as they do for authors in natural
languages.

···

On Fri, May 15, 2009 at 7:25 AM, Jeremy Henty <onepoint@starurchin.org> wrote:

On 2009-05-14, Jeff Moore <jcmoore@pressenter.com> wrote:

1.9.1 adds Enumerable#reduce as synonym (which makes more sense to
me) and still retains inject

Is one of #reduce or #inject deprecated in 1.9.1?

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

Jeremy Henty wrote:

···

On 2009-05-14, Jeff Moore <jcmoore@pressenter.com> wrote:

1.9.1 adds Enumerable#reduce as synonym (which makes more sense to
me) and still retains inject

Is one of #reduce or #inject deprecated in 1.9.1?

Regards,

Jeremy Henty

The RI entry has no preference or deprecation statement.

Regards,

jcm
--
Posted via http://www.ruby-forum.com/\.

nt> ...}

Personally I think it's good to have such synonyms, they make it
easier to be express subtleties just as they do for authors in natural
languages.

In my humble opinion I believe that having different words meaning the
same thing is not bad. It enables a certain ease to adapt our programs
slightly accordingly to slightly different cases. This is exactly what
they do for people expressing themselves in human idioms.

I guess that was what you meant, though I apologize for a certain lack
of subtlety.
:wink:
R.

···

On Fri, May 15, 2009 at 2:51 PM, Rick DeNatale <rick.denatale@gmail.com> wrote: