Last active
July 17, 2019 12:09
-
-
Save brackendev/b21b1342c5432bf39e0254e3f94de211 to your computer and use it in GitHub Desktop.
[Pharo] Detect division by zero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"https://rosettacode.org/wiki/Detect_division_by_zero" | |
| zeroDivide | | |
zeroDivide := [ :aBlock | | |
[ aBlock value. false ] on: ZeroDivide do: [ true ]. | |
]. | |
zeroDivide value: [2/1]. "false" | |
zeroDivide value: [2/0]. "true" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment