Collection.st
changeset 17554 e85acbe69361
parent 17409 987cd6ce6d2e
child 17572 2e3cc2277c96
equal deleted inserted replaced
17553:6d4e48b6091d 17554:e85acbe69361
   342      Abstract subclasses must redefine again."
   342      Abstract subclasses must redefine again."
   343 
   343 
   344     ^ self == Collection
   344     ^ self == Collection
   345 ! !
   345 ! !
   346 
   346 
   347 
       
   348 !Collection methodsFor:'Compatibility-Dolphin'!
   347 !Collection methodsFor:'Compatibility-Dolphin'!
   349 
   348 
   350 identityIncludes:anObject
   349 identityIncludes:anObject
   351     "return true, if the argument, anObject is in the collection.
   350     "return true, if the argument, anObject is in the collection.
   352      Same as #includesIdentical for Dolphin compatibility."
   351      Same as #includesIdentical for Dolphin compatibility."
   537 
   536 
   538 !Collection methodsFor:'accessing'!
   537 !Collection methodsFor:'accessing'!
   539 
   538 
   540 anElement
   539 anElement
   541     "return any element from the collection, 
   540     "return any element from the collection, 
   542      report an error if there is none"
   541      report an error if there is none.
       
   542      Use this to fetch the some element from a collection which is non-indexed or which
       
   543      has a non-numeric index. I.e. if someone gets an arbitrary collection which might be either indexable
       
   544      or not, anElement is a save way to access some element without a need to check for a proper key."
   543 
   545 
   544     self do: [:each | ^ each].
   546     self do: [:each | ^ each].
   545     self emptyCollectionError.
   547     self emptyCollectionError.
   546 
   548 
   547     "
   549     "
   548      #() anElement       -> Error
   550      #() anElement             -> Error
   549      #(1 2 3) anElement  -> 1
   551      #(1 2 3) anElement        -> 1
       
   552      #(1 2 3) asSet anElement  -> one of them (undefined, which one)
   550     "
   553     "
   551 !
   554 !
   552 
   555 
   553 at:aKey ifNilOrAbsentPut:valueBlock
   556 at:aKey ifNilOrAbsentPut:valueBlock
   554     "try to fetch the element at aKey. If either the key is invalid (as in a Dictionary)
   557     "try to fetch the element at aKey. If either the key is invalid (as in a Dictionary)
  5694 ! !
  5697 ! !
  5695 
  5698 
  5696 !Collection class methodsFor:'documentation'!
  5699 !Collection class methodsFor:'documentation'!
  5697 
  5700 
  5698 version
  5701 version
  5699     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.357 2015-02-04 19:58:36 stefan Exp $'
  5702     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.358 2015-02-25 13:12:31 cg Exp $'
  5700 !
  5703 !
  5701 
  5704 
  5702 version_CVS
  5705 version_CVS
  5703     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.357 2015-02-04 19:58:36 stefan Exp $'
  5706     ^ '$Header: /cvs/stx/stx/libbasic/Collection.st,v 1.358 2015-02-25 13:12:31 cg Exp $'
  5704 ! !
  5707 ! !
  5705 
  5708 
  5706 
  5709 
  5707 Collection initialize!
  5710 Collection initialize!