Not sure if there is a better/easier way, but this will only fill the array at compile time: template initArray[T](size: static int, value: T): untyped = block: var res: array[size, T] for i in 0 ..< res.len: res[i] = value res const arr = initArray[int](10, 500) const arr2 = initArray[string](5, "hey") proc main() = echo arr echo arr2 main() Run
- Fill array in C style nya
- Fill array in C style jyapayne
- Fill array in C style ElegantBeef
- Fill array in C style xigoi