Groups
Groups
Sign in
Groups
Groups
Ansible Project
Conversations
About
Send feedback
Help
What's The Difference?
38 views
Skip to first unread message
Tennis Smith
unread,
Sep 25, 2015, 8:42:47 AM
9/25/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Hi,
What's the difference, if any, between these 2 constructs?
when: varname is none
...and...
when: varname
| trim == ''
Are they equivalent, or is there a subtle difference?
-T
Brian Coca
unread,
Sep 25, 2015, 9:20:04 AM
9/25/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
they are actually quite different.
None is a 'null' while '' is an empty string, different types. They
both evaluate to False so they would be equivalent here:
when: varname
but not in the specific tests you show, if varname is None, it would
error out in the 2nd test and the empty string would not match in the
first case.
--
Brian Coca
Tennis Smith
unread,
Sep 25, 2015, 9:46:31 AM
9/25/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Thanks, Brian!
So, "when: varname" is equivalent to both of my examples?
-T
Brian Coca
unread,
Sep 25, 2015, 9:49:14 AM
9/25/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
not exactly, it will be false for the values of None and '' but not for ' '
--
Brian Coca
Reply all
Reply to author
Forward
0 new messages