Hi there I hope someone can help explain this to me. I’ve searched for the error in the forum and on github but I’m struggling to find an explanation. As far as I can tell it seems to be a bug in the compiler because arrays are enumerable in my experiments with simple functions. Compiling the below code on crystal v1.0.0 results in a error:
22 | @processor.call(@default, values)
^-----
Error: type must be Enumerable(Int32), not Array(Int32)
class A(T)
@processor : (T, Enumerable(T)) -> T
def self.first
->(default : T, list : Enumerable(T)) {
list.first || default
}
end
def initialize(@default : T, @processor = self.class.first())
end
def call(values : Array(T))
@processor.call(@default, values)
end
end
A(Int32).new(0).call([1,2,3])
I’m still learning crystal and haven’t read all of the handbook so any help would be great!