One AoC puzzle => many questions .
Today, I could not understand why in this simplified example:
class C def initialize(listing : String) @program = listing.split(',').map(&.to_i) end end C.new("1")
the compiler is not able to infer that
@program is an
Array(Int32). My reasoning is:
listinghas a type restriction
A one-liner seems to support that argument:
$ crystal eval 'p typeof("1,2".split(",").map(&.to_i))' Array(Int32)
Is my reasoning above wrong in some step? Are ivars special in some sense perhaps?