While searching for information on the notion of interface in Crystal Language, I came across this post in which @sija quotes the following example as the right way to define an interface in Crystal :
module RedisProtocol abstract def publish(channel, data) end class Redis include RedisProtocol # ... end class FakeRedis include RedisProtocol # ... end class MyClass @publisher : RedisProtocol # ... end
I have a problem with the
@publisher : RedisProtocol line in class
MyClass: AFAIK, a module cannot be instantiated, and here it seems to define a type.
I would be very happy to have explanations about this syntax, which I don’t understand either the meaning or the way to use it.