Skip to content

Instantly share code, notes, and snippets.

@bakkdoor
Created November 12, 2011 15:18
Show Gist options
  • Save bakkdoor/1360663 to your computer and use it in GitHub Desktop.
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: { ... }
# 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