I have the following code -
package "main"
var fibonacciNumbers = []int{0, 1}
func getIthFibo(i int) int {
if i < fibonacciNumbers.length {
return fibonacciNumbers[i]
}
...
}
However, I get an error at the if
condition -
fibonacciNumbers.length undefined - type []int has no field or method length
What I understood was that I created a slice with the elements 0 and 1 - so it should have a length of 2 but I get the above error.