Detect division by zero: Difference between revisions

m (→‎{{header|Phix}}: added syntax colouring the hard way, phix/basics)
Line 2,077:
Transcript show:'bad bad bad, but I already told you in the handler'.
].</lang>
Note: works in all Smalltalks: printf is avalableavailable in the public domain printfScanf package (or already included in your dialect).
 
Alternative version, which gets any block as argument, evaluates it and returns true, if ZeroDivide happened (works in all Smalltalks):
Line 2,094:
testZeroDivide value: [2/0] "------> true"</lang>
 
of course, as ZeroDivide inherits from Error, you could also write <landlang smalltalk>[...] on:Error do: [...]</lang>, thereby catching ANY error (as done in some other code examples here).
 
=={{header|SNOBOL4}}==
Anonymous user