Created
August 26, 2015 17:46
-
-
Save asterite/05e9e1fafa683431a510 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
module Moo | |
# Moo expects `foo` to return an Int32 | |
abstract def foo : Int32 | |
# `bar` adds 1 to it | |
def bar : Int32 | |
foo + 1 | |
end | |
# And maybe it provides other methods... | |
def bar2 | |
42 | |
end | |
end | |
# MooImpl decides inovking "foo" is an error. A real example | |
# is an IO which is read-only and raises in the | |
# `write(slice, count)` method. | |
class MooImpl | |
def foo | |
raise "Not implemented" | |
end | |
end | |
# The above will make `bar` have the type `NoReturn`, but it should still compile, | |
# even though NoReturn != Int32. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment