-
-
Save anonymous/1b2ebb80e514196dd90d to your computer and use it in GitHub Desktop.
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
define :factorial, :i => Integer do | |
if i < 1 then 1 else i * factorial(i - 1) end | |
end | |
# => #<Proc:0x00000001aaee10@type_assurance.rb:2 (lambda)> | |
factorial 5 | |
# => 120 | |
factorial 5.4 | |
# => #<RuntimeError: Error, expected Integer as argument for i in factorial> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment