Last active
July 19, 2017 14:05
-
-
Save mverzilli/6fca7057a65aa5639af91e16f7ff2ba4 to your computer and use it in GitHub Desktop.
Using modules as interfaces in Crystal
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 Foo | |
abstract def foo_sth | |
end | |
class SomeFoo | |
include Foo | |
end | |
class Bar | |
def initialize(@foo : Foo) | |
end | |
def bar_sth | |
@foo.foo_sth | |
end | |
end | |
puts Bar.new(SomeFoo.new).bar_sth |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment