Answers.Body: <p>It seems like you're trying to compare two EntryModel objects. Could you just compare their ids?</p>
  
  <pre><code>{% if rowParent.id == parent.id %}
      // Go
  {% endif %}
  </code></pre>
  
  <p>Also, try using <a href="http://twig.sensiolabs.org/doc/2.x/functions/dump.html" rel="nofollow noreferrer">Twig's dump() function</a> to find out exactly what's in those variables/objects.</p>
  
  <pre><code>&lt;pre&gt;
      {{ dump(parent) }}
  &lt;/pre&gt;
  </code></pre>
  
  <p>I believe you'll have to have <a href="https://craftcms.com/support/dev-mode" rel="nofollow noreferrer">devMode</a> enabled to use <code>dump()</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-12T14:55:34.617Z
Answers.Text: Yes, just after I've posted the question it hit me to compare it with ID variable as comparing strings didn't work. I still don't know why. Dumping EntryModels IDs gave me string length with an ID. It works now as expected.
Answers.UserDisplayName: Dominik Krulak
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-11T23:20:59.277Z
Answers.LastActivityDate: 2017-01-11T23:20:59.277Z
Answers.UserDisplayName: Alex Roper
Body: <p>I have two equal variables comparing each other which give me false.
  One variable is set out of ancestor entry in structure and another one out of ancestor entry as well.
  Both variables are set a bit differently.</p>
  
  <pre><code>{% set parent = craft.entries.ancestorOf(entry).order('lft desc').first() %}
  </code></pre>
  
  <p>Following variable is set within table field</p>
  
  <pre><code>{% for row in entryId.table %}
  
      {% set id = row.entryId %}
      {% set rowParent = craft.entries.ancestorOf(id).order('lft desc').first() %}
  
      {% if rowParent == parent %}
          // Go
      {% endif %}
  
  {% endfor %}
  </code></pre>
  
  <p>Both variables print the same text with case sensitive letters and spaces.</p>
  
Tags: <variable>
Title: Why two equal variables give false statement?
ThreadText: # Why two equal variables give false statement?
  
  (Asked by: username_0 on 2017-01-11)
  
  I have two equal variables comparing each other which give me false.
  One variable is set out of ancestor entry in structure and another one out of ancestor entry as well.
  Both variables are set a bit differently.
  
  ```
  {% set parent = craft.entries.ancestorOf(entry).order('lft desc').first() %}
  
  ```
  
  Following variable is set within table field
  
  ```
  {% for row in entryId.table %}
  
      {% set id = row.entryId %}
      {% set rowParent = craft.entries.ancestorOf(id).order('lft desc').first() %}
  
      {% if rowParent == parent %}
          // Go
      {% endif %}
  
  {% endfor %}
  
  ```
  
  Both variables print the same text with case sensitive letters and spaces.
  
  **Tags:** variable
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-11. Score: 3 | Accepted answer
  
  It seems like you're trying to compare two EntryModel objects. Could you just compare their ids?
  
  ```
  {% if rowParent.id == parent.id %}
      // Go
  {% endif %}
  
  ```
  
  Also, try using [Twig's dump() function](http://twig.sensiolabs.org/doc/2.x/functions/dump.html) to find out exactly what's in those variables/objects.
  
  ```
  <pre>
      {{ dump(parent) }}
  </pre>
  
  ```
  
  I believe you'll have to have [devMode](https://craftcms.com/support/dev-mode) enabled to use `dump()`.
  
  > **Comments:**
  > **username_0**: Yes, just after I've posted the question it hit me to compare it with ID variable as comparing strings didn't work. I still don't know why. Dumping EntryModels IDs gave me string length with an ID. It works now as expected.  
  
  ---
  
  