I’m running into something that is a little confusing for me, so I was wondering if anyone could provide clarification. I have the following code:
module MyInterface abstract def do_something : String end class MyClient include MyInterface def do_something 5 end end client = MyClient.new p client.do_something
This code compiles fine, but it is my understanding that it should not because the
do_something signature inside
MyClient does not match the abstract def. However, if I modify the abstract def to take any parameter, it gets enforced ie.
do_something(num : Int32) : String
Is this expected behavior? If so, what am I missing? Does the return type have to be explicitly given?