confused by fastled example code

I'm an old COBOL programmer and I'm venturing into Arduino. I'm very confused.

I'm looking at the example sketch 'ColorPalette' from the FastLED library. Can someone please give me the answer to this noddy question?

Looks to me like startIndex is created and set to zero and then 1 is added to it. Then the function is called to set up the chosen colours and the show command is issued.... Then we come back in at the top of the loop.

As far as I can see, startIndex will ALWAYS be 1 when FillLEDsFromPaletteColors is called.

What is the point of declaring it, setting it to zero, then adding 1?

Or does this behave in a way other than I have described?

void loop()

    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    FillLEDsFromPaletteColors( startIndex);;
    FastLED.delay(1000 / UPDATES_PER_SECOND);

No, because startIndex is qualified as "static"

(in fact the "= 0;" is redundant - it is guaranteed to be initialised to zero)

I'm an old COBOL programmer

Hey! Me too! Clean since 1980.

Thanks for the reply

so on the second pass through the loop, what effect does
static uint8_t startIndex = 0;
have? Is the line effectively ignored because startIndex already exists?

Thanks for the reply

The implied assignment has no effect on any pass through the function, because the initialisation was done before even main() was called.