<p>On a more philosophical note; Put yourself in the shoes of <code>first()</code>. It's a <strong>method</strong>, doing an important job in the Craft eco-system. It prides itself on returning the most important and relevant data in an efficient and unencumbered way. Serving up entry after entry, asset after asset, 24 hours a day, all week, all year. Never complaining, never getting any praise.</p>

<p>And you want to treat it like a simple <strong>property</strong>? As a dumb, brainless reference to some data that some other method created? How do you think that makes <code>first()</code> feel? How would <strong>you</strong> feel if someone treated <strong>you</strong> as property? </p>

<p>I know you're a good person with a big heart, Mats. I'm sure you will do the right thing and treat <code>first()</code> with the respect it deserves, even though it means that you'll have to write a few more characters a day.</p>

CC BY-SA 3.0
2016-02-27T13:25:57.083Z
If I could give this answer multiple upvotes, I would. FWIW, I do make sure that first() never leaves home without its parentheses. Poor little fella just looks so naked and defenseless without them.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2017-02-24T17:15:13.337Z
I've never considered having empathy for a method before.
jthomas
CC BY-SA 3.0
2016-02-27T12:09:13.913Z
2016-02-27T12:09:13.913Z
André Elvan
<p>There is absolutely no difference. Twig will recognize a method without parenthesis as simply being a method without parameters.</p>

<p>The only "gotcha" is if you <em>also</em> happen to have a property by the same name in your class. It's probably a bad idea to do so anyway, but if you have a method &amp; property sharing the same name, Twig will parse the parenthesis-less name as the property value instead.</p>

CC BY-SA 3.0
2016-02-26T16:15:54.797Z
2016-02-26T16:15:54.797Z
Lindsey D
<p>I think it was Ben Croker who mentioned this <a href="http://twig.sensiolabs.org/doc/templates.html#variables">nugget from the Twig docs</a> in his Craft course on development:</p>

<blockquote>
  <p>For convenience's sake <code>foo.bar</code> does the following things on the PHP layer:</p>
  
  <ul>
  <li>check if <code>foo</code> is an array and <code>bar</code> a valid <strong>element</strong>;</li>
  <li>if not, and if <code>foo</code> is an object, check that <code>bar</code> is a valid <strong>property</strong>;</li>
  <li>if not, and if <code>foo</code> is an object, check that <code>bar</code> is a valid <strong>method</strong> (even if <code>bar</code> is the constructor - use <code>__construct()</code> instead);</li>
  <li>if not, and if <code>foo</code> is an object, check that <code>getBar</code> is a valid <strong>method</strong>;</li>
  <li>if not, and if <code>foo</code> is an object, check that <code>isBar</code> is a valid <strong>method</strong>;</li>
  <li>if not, return a <strong>null value</strong>.</li>
  </ul>
  
  <p><code>foo['bar']</code> on the other hand only works with PHP arrays:</p>
  
  <ul>
  <li>check if <code>foo</code> is an array and bar a valid element;</li>
  <li>if not, return a null value.</li>
  </ul>
</blockquote>

<p>The more you find out about Twig, the more you don't know!</p>

CC BY-SA 3.0
2016-02-26T17:37:07.617Z
2016-02-26T17:37:07.617Z
RitterKnight
<p>So here's something I've never been able to figure out about Twig. Does it make a difference if you include the parenthesis for functions or not?</p>

<p>In other words, what is the difference – if any – between calling</p>

<pre><code>craft.entries.first
</code></pre>

<p>and</p>

<pre><code>craft.entries.first()
</code></pre>

<p>?</p>

<templating>
What is the difference between calling .first and .first()?
# What is the difference between calling .first and .first()?

(Asked by: username_0 on 2016-02-26)

So here's something I've never been able to figure out about Twig. Does it make a difference if you include the parenthesis for functions or not?
In other words, what is the difference – if any – between calling
craft.entries.first

and
craft.entries.first()

?

**Tags:** templating

---

## 3 answers

### Answer by username_4 on 2016-02-26. Score: 6 | Accepted answer

I think it was Ben Croker who mentioned this [nugget from the Twig docs](http://twig.sensiolabs.org/doc/templates.html#variables) in his Craft course on development:

> For convenience's sake `foo.bar` does the following things on the PHP layer:
>
> * check if `foo` is an array and `bar` a valid **element**;
> * if not, and if `foo` is an object, check that `bar` is a valid **property**;
> * if not, and if `foo` is an object, check that `bar` is a valid **method** (even if `bar` is the constructor - use `__construct()` instead);
> * if not, and if `foo` is an object, check that `getBar` is a valid **method**;
> * if not, and if `foo` is an object, check that `isBar` is a valid **method**;
> * if not, return a **null value**.
>
> `foo['bar']` on the other hand only works with PHP arrays:
>
> * check if `foo` is an array and bar a valid element;
> * if not, return a null value.

The more you find out about Twig, the more you don't know!


---

### Answer by username_1 on 2016-02-27. Score: 11

On a more philosophical note; Put yourself in the shoes of `first()`. It's a **method**, doing an important job in the Craft eco-system. It prides itself on returning the most important and relevant data in an efficient and unencumbered way. Serving up entry after entry, asset after asset, 24 hours a day, all week, all year. Never complaining, never getting any praise.

And you want to treat it like a simple **property**? As a dumb, brainless reference to some data that some other method created? How do you think that makes `first()` feel? How would **you** feel if someone treated **you** as property?

I know you're a good person with a big heart, Mats. I'm sure you will do the right thing and treat `first()` with the respect it deserves, even though it means that you'll have to write a few more characters a day.

> **Comments:**
> **username_0**: If I could give this answer multiple upvotes, I would. FWIW, I do make sure that first() never leaves home without its parentheses. Poor little fella just looks so naked and defenseless without them.  
> **username_2**: I've never considered having empathy for a method before.  

---

### Answer by username_3 on 2016-02-26. Score: 3

There is absolutely no difference. Twig will recognize a method without parenthesis as simply being a method without parameters.

The only "gotcha" is if you *also* happen to have a property by the same name in your class. It's probably a bad idea to do so anyway, but if you have a method & property sharing the same name, Twig will parse the parenthesis-less name as the property value instead.


---

