# foo.changed vs foo|changed

**URL:** <https://forum.ansible.com/t/foo-changed-vs-foo-changed/29435>\
**Category:** Ansible Project\
**Created:** [January 14, 2019, 4:20pm UTC](https://forum.ansible.com/t/foo-changed-vs-foo-changed/29435 "2019-01-14T16:20:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason3](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Jason3](https://forum.ansible.com/u/Jason3)\
**Post date:** [January 14, 2019, 4:20pm UTC](https://forum.ansible.com/t/foo-changed-vs-foo-changed/29435/1 "2019-01-14T16:20:17Z")

</div>

It’s unfortunately exceedingly difficult to search for “|” in most search engines, so finding info about this was not fruitful.

My question is, is there a difference between foo.changed and foo|changed, especially used in a “when:” parameter?

If there’s no difference, what’s the preferred syntax?

Thanks!

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [January 14, 2019, 4:53pm UTC](https://forum.ansible.com/t/foo-changed-vs-foo-changed/29435/2 "2019-01-14T16:53:25Z")

</div>

There is a difference, in fact the preferred syntax is actually `when: foo is changed`

There is no guarantee that the attribute will exist on a returned object. In addition to handling a non existent key/attribute, the changed test also has some more complex logic, where it will look into a sub-key called `results` too.

Historically we did not have jinja tests, which is what the `foo is changed` represents, so we registered them as filters (`foo|changed`). We are deprecating using tests as filters, which is why the `is` syntax is preferred there.

---

<div class="post-metadata">

**Author:** ![Jason3](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@Jason3](https://forum.ansible.com/u/Jason3)\
**Post date:** [January 14, 2019, 6:15pm UTC](https://forum.ansible.com/t/foo-changed-vs-foo-changed/29435/3 "2019-01-14T18:15:15Z")

</div>

Thanks for the full and complete answer!
