I wonder whether there is a difference in behaviour between the methods
Collection >> anySatisfy: aBlock and Collection >> contains: aBlock As far as I see they break the iteration and return true if the block evaluates to true and false if it never does (including the case of an empty collection). Am I mistaken? Steffen _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
#anySatisfy: is part of the ANSI Smalltalk specifications.
#contains: is what already existed in many Smalltalk dialects. hth, Adriaan. > I wonder whether there is a difference in behaviour between the methods > > Collection >> anySatisfy: aBlock and > Collection >> contains: aBlock > > As far as I see they break the iteration and return true if the block evaluates to true and false if it never does (including the case of an empty collection). Am I mistaken? > > Steffen > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > -- http://www.a3aan.st -- http://www.a3aan.st _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
They also convey different intent to the reader. At times I will
create a new method that calls another method to better communicate to the reader what I am doing. Roger whitney Via iPhone On May 27, 2008, at 10:25 AM, "Adriaan van Os" <[hidden email]> wrote: > #anySatisfy: is part of the ANSI Smalltalk specifications. > #contains: is what already existed in many Smalltalk dialects. > > hth, > Adriaan. > >> I wonder whether there is a difference in behaviour between the >> methods >> >> Collection >> anySatisfy: aBlock and >> Collection >> contains: aBlock >> >> As far as I see they break the iteration and return true if the block > evaluates to true and false if it never does (including the case of an > empty collection). Am I mistaken? >> >> Steffen >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >> > > -- > http://www.a3aan.st > > > > -- > http://www.a3aan.st > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
This is good opportunity to update the comment, because contains: states
to evaluate the block with all elements, but it simply doesn't. Thanks, Steffen Märcker anySatisfy: aBlock "Answer true if aBlock answers true for any element of the receiver. An empty collection answers false." contains: aBlock "Evaluate aBlock with each of the receiver's elements as the argument. Answer true if aBlock ever evaluates to true, otherwise answer false." self detect: aBlock ifNone: [^false]. ^true On Tue, 27 May 2008 21:04:20 +0200, Roger Whitney <[hidden email]> wrote: > They also convey different intent to the reader. At times I will > create a new method that calls another method to better communicate to > the reader what I am doing. > > Roger whitney > Via iPhone > > On May 27, 2008, at 10:25 AM, "Adriaan van Os" <[hidden email]> wrote: > >> #anySatisfy: is part of the ANSI Smalltalk specifications. >> #contains: is what already existed in many Smalltalk dialects. >> >> hth, >> Adriaan. >> >>> I wonder whether there is a difference in behaviour between the >>> methods >>> >>> Collection >> anySatisfy: aBlock and >>> Collection >> contains: aBlock >>> >>> As far as I see they break the iteration and return true if the block >> evaluates to true and false if it never does (including the case of an >> empty collection). Am I mistaken? >>> >>> Steffen >>> _______________________________________________ >>> vwnc mailing list >>> [hidden email] >>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >>> >> >> -- >> http://www.a3aan.st >> >> >> >> -- >> http://www.a3aan.st >> >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >> > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |