The if statement in Twig is comparable with the if statements of PHP. In the simplest form you can use it to test if a variable is defined, not empty or not false:

{% if users %}
    {% for user in users %}
      <li>{{ user.username|e }}</li>
    {% endfor %}
{% endif %}

For multiple branches elseif and else can be used like in PHP. You can use more complex expressions there too:

{% if kenny.sick %}
  Kenny is sick.
{% elseif kenny.dead %}
  You killed Kenny!
{% else %}
  Kenny looks okay --- so far
{% endif %}