diff --git a/moo/kernel/Collect.moo b/moo/kernel/Collect.moo index 7727981..356a9bb 100644 --- a/moo/kernel/Collect.moo +++ b/moo/kernel/Collect.moo @@ -35,17 +35,6 @@ class Collection(Object) ^self subclassResponsibility: #do } - method detect: block - { - self detect: block ifNone: [ ^self error: 'not found' ]. - } - - method detect: block ifNone: exception_block - { - self do: [ :el | if (block value: el) { ^el } ]. - ^exception_block value. - } - method collect: block { | coll | @@ -54,6 +43,18 @@ class Collection(Object) ^coll } + method detect: block + { + ^self detect: block ifNone: [ ^self error: 'not found' ]. + } + + method detect: block ifNone: exception_block + { + ## returns the first element for which the block evaluates to true. + self do: [ :el | if (block value: el) { ^el } ]. + ^exception_block value. + } + method select: condition_block { | coll | @@ -457,6 +458,17 @@ class OrderedCollection(SequenceableCollection) ^obj. } + method add: obj + { + ^self addLast: obj. + } + + method addAll: coll + { + coll do: [:el | self addLast: el ]. + ^coll. + } + method removeFirst { | obj |