You are viewing an older version of the site. Click here to view
the latest version of this page. (This may be a dead link, if so, try the root page of the docs
here.)
== cslice ==
Copy Code
The output would be:
Dynamically creates an array slice, which can be used with array_get (or the [bracket notation]) to get a range of elements. cslice(0, 5) is equivalent to 0..5 directly in code, however with this function you can also do cslice(@var, @var), or other more complex expressions, which are not possible in static code.
=== Vital Info ===
{| style="width: 40%;" cellspacing="1" cellpadding="1" border="1" class="wikitable"
|-
! scope="col" width="20%" |
! scope="col" width="80%" |
|-
! scope="row" | Name
| cslice
|-
! scope="row" | Returns
| slice
|-
! scope="row" | Usages
| from, to
|-
! scope="row" | Throws
| [[../objects/ms.lang.CastException|ms.lang.CastException]]
|-
! scope="row" | Since
| 3.3.1
|-
! scope="row" | Restricted
| No
|-
! scope="row" | Optimizations
| [[../../Optimizer#NO_SIDE_EFFECTS|NO_SIDE_EFFECTS]]
|}
=== Usages ===
cslice(from, to)=== Examples === ====Example 1==== Basic usage Given the following code:
array(1, 2, 3)[cslice(0, 1)]

1 {{function|array}}(1, 2, 3)[{{function|cslice}}(0, 1)]
:{1, 2}
Find a bug in this page? Edit this page yourself, then submit a pull request. (Note this page is automatically generated from the documentation in the source code.)