with 3 OptionalArguments
authorClaus Gittinger <cg@exept.de>
Thu, 22 Aug 2002 16:27:36 +0200
changeset 6728 a4fc441779dc
parent 6727 30e331bcfeed
child 6729 ce3a5460987a
with 3 OptionalArguments
Object.st
--- a/Object.st	Thu Aug 22 13:05:03 2002 +0200
+++ b/Object.st	Thu Aug 22 16:27:36 2002 +0200
@@ -5926,7 +5926,8 @@
 
 perform:aSelector withOptionalArgument:optionalArg1 and:optionalArg2
     "send aSelector-message to the receiver.
-     If the message expects argument1, pass optionalArg1 and optionalArg2 as required."
+     Depending on the number of arguments the message expects,
+     pass either none, 1, or 2 arguments."
 
     |numArgs|
 
@@ -5951,6 +5952,37 @@
     "
 !
 
+perform:aSelector withOptionalArgument:optionalArg1 and:optionalArg2 and:optionalArg3
+    "send aSelector-message to the receiver.
+     Depending on the number of arguments the message expects,
+     pass either none, 1, 2 or 3 arguments."
+
+    |numArgs|
+
+    numArgs := aSelector numArgs.
+    numArgs == 0 ifTrue:[
+        ^ self perform:aSelector
+    ].
+    numArgs == 1 ifTrue:[
+        ^ self perform:aSelector with:optionalArg1
+    ].
+    numArgs == 2 ifTrue:[
+        ^ self perform:aSelector with:optionalArg1 with:optionalArg2
+    ].
+    ^ self perform:aSelector with:optionalArg1 with:optionalArg2 with:optionalArg3.
+
+    "
+     |rec sel|
+
+     rec := -1.
+     sel := #abs.
+     rec perform:sel withOptionalArgument:2.
+
+     sel := #max:.
+     rec perform:sel withOptionalArgument:2.
+    "
+!
+
 performMethod:aMethod
     "invoke aMethod on the receiver.
      The method should be a zero-argument method.
@@ -8765,6 +8797,6 @@
 !Object class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.420 2002-08-15 19:11:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.421 2002-08-22 14:27:36 cg Exp $'
 ! !
 Object initialize!