Search code examples
crystal-langamber-framework

instance var of CategoryController must be (Array(Array(Array(Int64 | String) | Array(String))) | Nil)


unable to store data contain in abc. it's showing an error

instance variable @ar of CategoryController must be (Array(Array(Array(Int64 | String) | Array(String))) | Nil), not Array(Array(Int64 | String) | Array(String)))

code sample:

 abc = [["", "Select"], [6_i64, "some"]]

 puts abc.class # => Array(Array(Int64 | String) | Array(String))

 @ar = [] of Array(Array(Int64 | String) | Array(String))

 @ar = abc # showing error

Solution

  • The code is working here, going to need more context to find out the error. And also, comments should be done with # Comment here.

    A guess would be that @ar in CategoryController is defined incorrectly.