I typed the following:
func Fib(i int) long -> if i <= 0 { 0 } else if i == 1 { 1 } else { Fib(i-1)+Fib(i-2) }
var numbers map[int, long]
So far so good, then:
for var i = 1; i <= 20; i++ {
numbers[i] = Fib(i)
}
The result was a GS9999 Object reference not set to an instance of an object
I then realized that I could have done:
var numbers map[int, long] = map[int, long]{}
or simply:
var numbers = map[int, long]{}
but not this:
var numbers map[int, long] = {}
Which results in GS0005: Unexpected token <OpenBraceToken>, expected <IdentifierToken>.
I typed the following:
So far so good, then:
The result was a
GS9999 Object reference not set to an instance of an objectI then realized that I could have done:
or simply:
but not this:
Which results in
GS0005: Unexpected token <OpenBraceToken>, expected <IdentifierToken>.