You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As @straight-shoota says, it's indeed covariance and contravariance.
Right now there's a bit of inconsistency of what Array(Int32 | String) means depending on when you write it: a type restriction, a return value, the type of an instance variable. No decision has been taken yet.
But yeah, essentially a duplicate of #3803, so closing.
While this works: https://play.crystal-lang.org/#/r/5ro7
But this gets a compile error: https://play.crystal-lang.org/#/r/5rmy
Output:
I was kinda hoping returning
Array(Int32)
from a method that expects a return type ofArray(Int32 | String)
should pass.The text was updated successfully, but these errors were encountered: