+at:ifPresent:
authorClaus Gittinger <cg@exept.de>
Thu, 31 May 2007 18:28:08 +0200
changeset 10587 d0e5f934141a
parent 10586 7249c850299f
child 10588 7043b70ff150
+at:ifPresent:
NameSpace.st
--- a/NameSpace.st	Thu May 31 18:00:24 2007 +0200
+++ b/NameSpace.st	Thu May 31 18:28:08 2007 +0200
@@ -321,6 +321,19 @@
     "Modified: 8.11.1996 / 21:40:01 / cg"
 !
 
+at:aKey ifPresent:aBlock
+    "try to retrieve the value stored at aKey.
+     If there is nothing stored under this key, do nothing.
+     Otherwise, evaluate aBlock, passing the retrieved value as argument."
+
+    (self includesKey:aKey) ifTrue:[
+        ^ aBlock value:(self at:aKey)
+    ].
+    ^ nil
+
+    "Modified: / 31-05-2007 / 17:50:46 / cg"
+!
+
 at:classNameSymbol put:aClass
     "add a class to the namespace defined by the receiver"
 
@@ -591,5 +604,5 @@
 !NameSpace class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.65 2007-02-05 15:40:19 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/NameSpace.st,v 1.66 2007-05-31 16:28:08 cg Exp $'
 ! !