forked from solstice/solstice
27 lines
718 B
Markdown
27 lines
718 B
Markdown
|
|
# string_Substring
|
||
|
|
Get a substring of a string.
|
||
|
|
|
||
|
|
## Arguments
|
||
|
|
- str (string): the string to get a substring of.
|
||
|
|
- start (int): starting index of the substring.
|
||
|
|
- end (int): ending index of the substring.
|
||
|
|
|
||
|
|
## Returns
|
||
|
|
substring (string): the substring of the given string.
|
||
|
|
|
||
|
|
## Raises
|
||
|
|
- `AllocFail`: raised if Ground failed to allocate memory for the new string.
|
||
|
|
- `EndBeforeStart`: raised if the `end` index is less than the `start` index.
|
||
|
|
- `OutOfBounds`: raised if either the `end` or `start` index is outside the bounds of the string.
|
||
|
|
|
||
|
|
## Example
|
||
|
|
### Ground
|
||
|
|
```python
|
||
|
|
call !string_Substring "Hello, World!" 1 3 &sub
|
||
|
|
println $sub # "ell"
|
||
|
|
```
|
||
|
|
|
||
|
|
### Solstice
|
||
|
|
```c
|
||
|
|
puts string_Substring("Hello, World!", 1, 3) // "ell"
|
||
|
|
```
|