You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a is not defined, so its value is nil. nil does not have an empty? property, so the result of the whole keypath is nil, which doesn't match any of the cases so the else is hit.
It's a weird test though, since empty? is not actually a thing in Liquid (unless you expose it specifically in a drop or hash).
@pushrax Ah, so you're saying that the case statement does not actually compare based on truthiness, correct? I see that the following does not use truthiness as a basis for comparison either:
{% case nil %}{% when false %}FALSE{% when true %}TRUE{%else%}NOT TRUE OR FALSE{% endcase %}
--> NOT TRUE OR FALSE
{% case 0 %}{% when true %}TRUE{% when false %}FALSE{%else%}NOT TRUE OR FALSE{% endcase %}
--> NOT TRUE OR FALSE
Without knowing that, I would have expected those to return "FALSE" and "TRUE", respectively....
Activity
pushrax commentedon Jul 6, 2015
ais not defined, so its value isnil.nildoes not have anempty?property, so the result of the whole keypath isnil, which doesn't match any of the cases so theelseis hit.It's a weird test though, since
empty?is not actually a thing in Liquid (unless you expose it specifically in a drop or hash).mikebridge commentedon Jul 6, 2015
@pushrax Ah, so you're saying that the
casestatement does not actually compare based on truthiness, correct? I see that the following does not use truthiness as a basis for comparison either:Without knowing that, I would have expected those to return "FALSE" and "TRUE", respectively....
pushrax commentedon Jul 6, 2015
It works similarly to ruby when using equality rather than truthiness (in ruby
nil != false).mikebridge commentedon Jul 6, 2015
Ok, thanks for the clarification!