Respond to an unknown method call: Difference between revisions

Added Mathematica
m (→‎{{header|Sidef}}: minor code simplification)
(Added Mathematica)
Line 565:
object.hello() -->You called the method hello
</lang>
 
=={{header|Mathematica}}==
By default, when evaluating a symbol's <code>DownValues</code>, Mathematica picks the most specific.
<lang Mathematica>obj[foo] = "This is foo.";
obj[bar] = "This is bar.";
obj[f_Symbol] := "What is " <> SymbolName[f] <> "?";
Print[obj@foo];
Print[obj@bar];
Print[obj@baz];</lang>
{{out}}
<pre>This is foo.
This is bar.
What is baz?</pre>
 
=={{header|Object Pascal}}==