When to use " is same as" and when to use "==" {% if foo is same as('bar') %}


vs.

{% if foo == 'bar' %}


When to use first and when to use second? Does one of them has advantages over another?
Looking at the Twig code, they have this documented for the “same as” test:


  Checks if a variable is the same as another one (=== in PHP).


I won’t re-hash the details of === vs. == in PHP because there is an excellent comparison here: https://stackoverflow.com/questions/80646/how-do-the-php-equality-double-equals-and-identity-triple-equals-comp

The money quote is:


  == compares the values of variables for equality, type casting as necessary. === checks if the two variables are of the same type AND have the same value.


And here’s what the PHP docs have to say:

http://www.php.net/manual/en/language.operators.comparison.php