Skip to content

Instantly share code, notes, and snippets.

@mverzilli
Last active July 19, 2017 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mverzilli/6fca7057a65aa5639af91e16f7ff2ba4 to your computer and use it in GitHub Desktop.
Save mverzilli/6fca7057a65aa5639af91e16f7ff2ba4 to your computer and use it in GitHub Desktop.
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