A slicing operation is a simple way to extract a range of elements from a container. The boo compiler supports native slicing operations on lists, arrays and strings. Support for user defined slicing operations is planned but currently not implemented.
A slicing operation is applied to a container through the following syntax:
When firstIndexWanted is omitted it is assumed to be 0.
When firstIndexNotWanted is omitted it is assumed to be equals to
When step is omitted it is assumed to be 1.
Differences between collection types
Consider the following example:
You must specify a parameter is a sliceable type when using it with methods:
the above code will result on compile time error The type 'System.Object' does not support splicing'. This is because the boo compiler cannot predict that you want to pass a collection to the method, and since the type Object is neither a collection or array, we got the error. To handle that, explicitly tell the compiler that you will pass a collection to the method: