Respond to an unknown method call: Difference between revisions
m
fix formatting accident
(Add SuperCollider example) |
m (fix formatting accident) |
||
Line 1,092:
True
slate[2]></lang>
=={{header|SuperCollider}}==▼
<lang SuperCollider>▼
Ingorabilis {▼
tell {▼
"I told you so".postln;▼
}▼
find {▼
"I found nothing".postln▼
}▼
doesNotUnderstand { |selector ... args|▼
"Method selector '%' not understood by %\n".postf(selector, this.class);▼
"Giving you some good arguments in the following".postln;▼
args.do { |x| x.postln };▼
"And now I delegate the method to my respected superclass".postln;▼
super.doesNotUnderstand(selector, args)▼
}▼
}▼
</lang>▼
Usage:▼
Line 1,170 ⟶ 1,145:
There is a utility method for exactly the above (it catches only #fooBar to the original receiver):
<lang smalltalk>anObject perform:#fooBar ifNotUnderstood:[ ...some alternative code and return value... ].</lang>
▲=={{header|SuperCollider}}==
▲<lang SuperCollider>
▲Ingorabilis {
▲ tell {
▲ "I told you so".postln;
▲ }
▲ find {
▲ "I found nothing".postln
▲ }
▲ doesNotUnderstand { |selector ... args|
▲ "Method selector '%' not understood by %\n".postf(selector, this.class);
▲ "Giving you some good arguments in the following".postln;
▲ args.do { |x| x.postln };
▲ "And now I delegate the method to my respected superclass".postln;
▲ super.doesNotUnderstand(selector, args)
▲ }
▲}
▲</lang>
▲Usage:
<lang SuperCollider>
|