# HG changeset patch # User Claus Gittinger # Date 939296234 -7200 # Node ID 211a7f44946db2f6080b4a2c99e8eeef9060e20a # Parent 3f6a8c36892596f67ddc239f12430b0a5c757f90 added #at:ifPresent: diff -r 3f6a8c368925 -r 211a7f44946d Dictionary.st --- a/Dictionary.st Thu Oct 07 13:35:01 1999 +0200 +++ b/Dictionary.st Thu Oct 07 13:37:14 1999 +0200 @@ -248,6 +248,18 @@ "Modified: / 26.2.1998 / 19:10:09 / stefan" ! +at:aKey ifPresent:aBlock + "if the receiver contains an element stored under aKey, + retrieve it and evaluate aBlock passing the element as argument, + return the blocks value. + If not, do nothing and return nil." + + |v| + + v := self at:aKey ifAbsent:[^ nil]. + ^ aBlock value:v. +! + at:aKey put:anObject "add the argument anObject under key, aKey to the receiver. Return anObject (sigh). @@ -1431,5 +1443,5 @@ !Dictionary class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.60 1998-11-09 21:34:15 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Dictionary.st,v 1.61 1999-10-07 11:37:14 cg Exp $' ! !