8648 If it's understood, return the method's returned value, |
8647 If it's understood, return the method's returned value, |
8649 otherwise return the value of the exceptionBlock. |
8648 otherwise return the value of the exceptionBlock. |
8650 Read this: |
8649 Read this: |
8651 Many programmers do an Error-handle to perform a similar |
8650 Many programmers do an Error-handle to perform a similar |
8652 checked-message send. However, this method is more specific, |
8651 checked-message send. However, this method is more specific, |
8653 in that only errors for the given selector are caught - not any other |
8652 in that only errors for the given selector and this receiver are caught - not any other |
8654 doesNotUnderstand, and especially not any other error." |
8653 doesNotUnderstand, and especially not any other error." |
8655 |
8654 |
8656 ^ [ |
8655 ^ [ |
8657 self perform:aSelector. |
8656 self perform:aSelector. |
8658 ] on:MessageNotUnderstood do:[:ex | |
8657 ] on:MessageNotUnderstood do:[:ex | |
8659 "/ reject, if the bad message is not the one |
8658 "/ reject, if the bad message is not the one |
8660 "/ we have sent originally |
8659 "/ we have sent originally |
8661 (ex selector == aSelector and:[ex receiver == self]) ifFalse:[ |
8660 (ex selector == aSelector and:[ex receiver == self]) ifFalse:[ |
8662 ex reject |
8661 ex reject |
8663 ]. |
8662 ]. |
8664 exceptionBlock value |
8663 exceptionBlock value |
8665 ]. |
8664 ]. |
8666 |
8665 |
8667 " |
8666 " |
8668 1.2345 perform:#foo ifNotUnderstood:['sorry'] |
8667 1.2345 perform:#foo ifNotUnderstood:['sorry'] |
8669 1.2345 perform:#sqrt ifNotUnderstood:['sorry'] |
8668 1.2345 perform:#sqrt ifNotUnderstood:['sorry'] |
8670 12345 perform:#sqrt ifNotUnderstood:['sorry'] |
8669 12345 perform:#sqrt ifNotUnderstood:['sorry'] |
8671 " |
8670 " |
8672 |
8671 |
8673 "Modified (comment): / 13-02-2017 / 20:27:38 / cg" |
|
8674 "Modified: / 15-03-2017 / 17:05:58 / stefan" |
8672 "Modified: / 15-03-2017 / 17:05:58 / stefan" |
|
8673 "Modified (comment): / 03-05-2020 / 13:19:31 / cg" |
8675 ! |
8674 ! |
8676 |
8675 |
8677 perform:aSelector with:argument ifNotUnderstood:exceptionBlock |
8676 perform:aSelector with:argument ifNotUnderstood:exceptionBlock |
8678 "try to send message aSelector to the receiver. |
8677 "try to send message aSelector to the receiver. |
8679 If it's understood, return the method's returned value, |
8678 If it's understood, return the method's returned value, |