总而言之,我有一个数组,其中包含几个如下所示的数组:
[0, 1, 2, 3, {'key': 'example', 'id': 0}]
.
我有一个看起来像这样的循环:
{% for arr in array %} // Array including the array I showed above
{% for item in arr %} // Array of pattern I showed above
{% if item.key == key and item.id == id %}
If-1 True
{% else %}
If-2 False
{% endif %}
{% if (elem == key and item == id) or (item.key == key and item.id == id %}
If-2 True
{% else %}
If-2 False
{% endif %}
{% endloop %}
{% endloop %}
如您所见,第二个 If 语句包括第一个 If 语句的条件,以及第二个条件之间的
or
。根据我过去的编程经验,这应该意味着如果两个条件中的任何一个是true
,整个If语句应该是true
。
然而这里不是这样的。当第二个语句仍然返回
If-1 True
字符串时,第一个语句将返回 If-2 False
字符串。
为什么会这样?
or
在 Liquid 中的工作方式不同吗?