Skip to content

Instantly share code, notes, and snippets.

@mverzilli
Last active Jul 19, 2017
Embed
What would you like to do?
Using modules as interfaces in Crystal
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