It does not work what @mora wrote. Even with corrected code. See: proc sum[T](x: Container[T]): T = for i in 0..<x.len: result += get(i, 0)
should be proc sum[T](x: Container[T]): T = for i in 0..<x.len: result += get(x, i) though.
It does not work what @mora wrote. Even with corrected code. See: proc sum[T](x: Container[T]): T = for i in 0..<x.len: result += get(i, 0)
should be proc sum[T](x: Container[T]): T = for i in 0..<x.len: result += get(x, i) though.