Answers.Body: <p>Your first example (<code>.id('not' ~ entry.id)</code>) will exclude that entry ID from the results on in the actual database query.</p>
  
  <p>Your second example will grab all of the entries that satisfy the criteria, then from the PHP/Twig side, then use the <code>|without</code> filter to loop through the array results and remove the ones that match the criteria.</p>
  
  <p>Pretty sure your 2nd one won't work as you're expecting though, since you're telling it to remove an <code>entry.id</code>, which is an integer, but the results are an array of Entry elements. It <em>might</em> work just using <code>entry</code> instead, but I'm guessing the <code>|without</code> filter isn't smart enough to work on entire objects.</p>
  
  <p>Long story short, use the 1st example.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-22T18:34:57.903Z
Answers.LastActivityDate: 2016-12-22T18:34:57.903Z
Answers.UserDisplayName: Brad Bell
Body: <p>Here is an example of code I'm trying to use to eliminating have to iterate comparing the current <code>entry.title</code> to the related to entry.title then omitting it.</p>
  
  <pre><code>{% set entries = craft.entries.relatedTo(context).limit(MAX_FILLERS).id('not' ~ entry.id) %}
  
  {% set entries = craft.entries.relatedTo(context).limit(MAX_FILLERS)|without(entry.id) %}
  </code></pre>
  
  <p>Current code I'm trying to get around with a single relatedTo call.</p>
  
  <pre><code>{% set entriesUnfiltered = craft.entries.relatedTo(context).limit(MAX_FILLERS).search('-title:'+entry.title) %}
  
  {% set entries = [] %}
  
  {# Removing self entries #}
  {% for e in entriesUnfiltered%}
      {% if e.title not in entry %}
          {% set entries = entries|merge([e]) %}
      {% endif %}
  {% endfor %}
  </code></pre>
  
Tags: <craft3>
Title: Can someone explain to me the difference between 'not' and without?
ThreadText: # Can someone explain to me the difference between 'not' and without?
  
  (Asked by: username_0 on 2016-12-22)
  
  Here is an example of code I'm trying to use to eliminating have to iterate comparing the current `entry.title` to the related to entry.title then omitting it.
  
  ```
  {% set entries = craft.entries.relatedTo(context).limit(MAX_FILLERS).id('not' ~ entry.id) %}
  
  {% set entries = craft.entries.relatedTo(context).limit(MAX_FILLERS)|without(entry.id) %}
  
  ```
  
  Current code I'm trying to get around with a single relatedTo call.
  
  ```
  {% set entriesUnfiltered = craft.entries.relatedTo(context).limit(MAX_FILLERS).search('-title:'+entry.title) %}
  
  {% set entries = [] %}
  
  {# Removing self entries #}
  {% for e in entriesUnfiltered%}
      {% if e.title not in entry %}
          {% set entries = entries|merge([e]) %}
      {% endif %}
  {% endfor %}
  
  ```
  
  **Tags:** craft3
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-12-22. Score: 2 | Accepted answer
  
  Your first example (`.id('not' ~ entry.id)`) will exclude that entry ID from the results on in the actual database query.
  
  Your second example will grab all of the entries that satisfy the criteria, then from the PHP/Twig side, then use the `|without` filter to loop through the array results and remove the ones that match the criteria.
  
  Pretty sure your 2nd one won't work as you're expecting though, since you're telling it to remove an `entry.id`, which is an integer, but the results are an array of Entry elements. It *might* work just using `entry` instead, but I'm guessing the `|without` filter isn't smart enough to work on entire objects.
  
  Long story short, use the 1st example.
  
  
  ---
  
  