Created
November 12, 2011 15:18
-
-
Save bakkdoor/1360663 to your computer and use it in GitHub Desktop.
Sample method with requirements on the argument. You can also define post conditions via ensure: { ... }
This file contains hidden or 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
# usage: | |
class Fixnum { | |
def / other { | |
require: @{ | |
other class is: Fixnum | |
other is > 0 | |
} body: { | |
# actual method body goes here.. | |
} | |
} | |
} | |
f = 10 / 2 | |
g = 10 / 0 # requirement error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment