Make sketch shorter, simply

Is there a link to a topic where explane this?

Which explains what? How to use an if statement?

if(currentValue != previousValue)
{
   HeyTheValueChanged();
}
previousValue = currentValue;