Variable question

Hi,
I've encountered this video on youtube :

around the 32nd minute a variable called lastCode appears in the code.

My question is why there is the necessity of use of this variable and why if even is in use in the loop? Can somebody give some clarifications? Thank you.

Rather than us all waste 30+ minutes watching a video, why don't you summarise?

BorislavLukanov:
around the 32nd minute a variable called lastCode appears in the code.

My question is why there is the necessity of use of this variable and why if even is in use in the loop? Can somebody give some clarifications? Thank you.

According to comments - it used to store last received code and repeat it. If you need more detailed answer - please post code here. It's painful to analyze code from a video.

See the value's use in the code:

void loop()
{
  if (irrecv.decode(&results)) //this checks to see if a code has been received
  {
    if (results.value == 0xFFFFFFFF)
    {
      // If Repeat then use last code received
      results.value = lastCode;
    }
    
    if (results.value == 0xFF22DD)
    {
      // Left Button Pressed 
      lastCode = results.value;  // Save the code in case a repeat code arrives
      // Move left 2 degrees
      pos += 2;
      // Prevent position above 180
      if (pos > 180)
      {
        pos = 180;
      }
      myservo.write(pos);
    }
  }
}