Smalltalk.st
changeset 21363 dbd8602f07b1
parent 21338 82931ca66d88
child 21365 730217a3920c
--- a/Smalltalk.st	Mon Feb 06 15:40:39 2017 +0100
+++ b/Smalltalk.st	Tue Feb 07 11:00:05 2017 +0100
@@ -1209,6 +1209,22 @@
     "Smalltalk keyAtValue:Object"
 !
 
+keyAtValue:anObject ifAbsent:exceptionValue
+    "return the symbol under which anObject is stored - or the value from exceptionValue"
+
+    self keysDo:[:aKey |
+        (self at:aKey) == anObject ifTrue:[^ aKey]
+    ].
+    ^ exceptionValue value
+
+    "
+     Smalltalk keyAtValue:Object ifAbsent:#foo
+     Smalltalk keyAtValue:1234 ifAbsent:#foo
+    "
+
+    "Created: / 07-02-2017 / 10:58:51 / cg"
+!
+
 keys
     "return a collection with all keys in the Smalltalk dictionary"