mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Numbers and array indices can be negative
This commit is contained in:
+3
-3
@@ -30,7 +30,7 @@ Numbers include floats and integers:
|
|||||||
```liquid
|
```liquid
|
||||||
{% raw %}
|
{% raw %}
|
||||||
{% assign my_int = 25 %}
|
{% assign my_int = 25 %}
|
||||||
{% assign my_float = 39.756 %}
|
{% assign my_float = -39.756 %}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ To access all the items in an array, you can loop through each item in the array
|
|||||||
|
|
||||||
### Accessing specific items in arrays
|
### Accessing specific items in arrays
|
||||||
|
|
||||||
You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero.
|
You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero. A negative index will count from the end of the array.
|
||||||
|
|
||||||
<p class="code-label">Input</p>
|
<p class="code-label">Input</p>
|
||||||
```liquid
|
```liquid
|
||||||
@@ -108,7 +108,7 @@ You can use square bracket `[` `]` notation to access a specific item in an arra
|
|||||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||||
{{ site.users[0] }}
|
{{ site.users[0] }}
|
||||||
{{ site.users[1] }}
|
{{ site.users[1] }}
|
||||||
{{ site.users[3] }}
|
{{ site.users[-1] }}
|
||||||
{% endraw %}
|
{% endraw %}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user