Answers.Body: <p>Try adding <code>find()</code> to your ElementCriteriaModel, I think without that function you're not actually saving your entries as an array in your variable <code>todaysOneOffEvents</code> yet.</p>
  
  <p>Here's what I <a href="http://buildwithcraft.com/docs/templating/elementcriteriamodel#fetching-the-elements" rel="nofollow">found in the Docs</a>:</p>
  
  <blockquote>
    <p>You don’t actually need to call <code>find()</code> yourself though: It will be called automatically as soon as the ElementCriteriaModel is treated like an array (that is, as soon as you check how many elements there are using the <code>|length</code> filter, or start looping through the elements with a <code>{% for %}</code> loop).</p>
  </blockquote>
  
  <p>We learn that merging doesn't "treat it like an array", good to know.</p>
  
  <p>Edit: You can't use the <code>length</code> filter to "convert" the content of the variable to an actual array. Removed that part from the answer.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-22T14:00:38.660Z
Answers.Text: That's the bunny. Cheers.
Answers.UserDisplayName: Clive Portman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-21T14:38:54.120Z
Answers.LastActivityDate: 2014-10-21T15:02:02.410Z
Answers.LastEditDate: 2014-10-21T15:02:02.410Z
Answers.UserDisplayName: carlcs
Body: <p>Can anyone help me work out why the following returns the error "The merge filter only works with arrays or hashes."?</p>
  
  <pre><code>{# CREATE ARRAY TO HOLD ALL OF TODAY'S EVENTS #}
  {% set todaysEvents = [] %}
  
  {# GET TODAY'S ONE-OFF EVENTS #}
  {# RETURNS ENTRIES NICELY IF LOOPED THROUGH #}
  {% set todaysOneOffEvents = craft.entries.section('events').eventDate('= '~today | date("Y-m-d")) %}
  
  {# ADD TODAY'S ONE-OFF EVENTS TO TODAY'S EVENTS %}
  {# THIS RETURNS MERGE ARRAY ERROR #}
  {% set todaysEvents = todaysEvents|merge(todaysOneOffEvents) %}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2014-10-21T15:11:07.673Z
Comments.Text: Thanks to this I finally learned the difference between an ElementCriteriaModel an an array of entries. The magic happens within the `find()` function :) Thanks for the question, Clive!
Comments.UserDisplayName: carlcs
Tags: <array><merge>
Title: Shouldn't this merge be working?
ThreadText: # Shouldn't this merge be working?
  
  (Asked by: username_0 on 2014-10-21)
  
  Can anyone help me work out why the following returns the error "The merge filter only works with arrays or hashes."?
  
  ```
  {# CREATE ARRAY TO HOLD ALL OF TODAY'S EVENTS #}
  {% set todaysEvents = [] %}
  
  {# GET TODAY'S ONE-OFF EVENTS #}
  {# RETURNS ENTRIES NICELY IF LOOPED THROUGH #}
  {% set todaysOneOffEvents = craft.entries.section('events').eventDate('= '~today | date("Y-m-d")) %}
  
  {# ADD TODAY'S ONE-OFF EVENTS TO TODAY'S EVENTS %}
  {# THIS RETURNS MERGE ARRAY ERROR #}
  {% set todaysEvents = todaysEvents|merge(todaysOneOffEvents) %}
  
  ```
  
  **Tags:** array, merge
  
  > **Comments:**
  > **username_1**: Thanks to this I finally learned the difference between an ElementCriteriaModel an an array of entries. The magic happens within the `find()` function :) Thanks for the question, username_0!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-10-21. Score: 6 | Accepted answer
  
  Try adding `find()` to your ElementCriteriaModel, I think without that function you're not actually saving your entries as an array in your variable `todaysOneOffEvents` yet.
  
  Here's what I [found in the Docs](http://buildwithcraft.com/docs/templating/elementcriteriamodel#fetching-the-elements):
  
  > You don’t actually need to call `find()` yourself though: It will be called automatically as soon as the ElementCriteriaModel is treated like an array (that is, as soon as you check how many elements there are using the `|length` filter, or start looping through the elements with a `{% for %}` loop).
  
  We learn that merging doesn't "treat it like an array", good to know.
  
  Edit: You can't use the `length` filter to "convert" the content of the variable to an actual array. Removed that part from the answer.
  
  > **Comments:**
  > **username_0**: That's the bunny. Cheers.  
  
  ---
  
  