forked from solstice/solstice
started writing lexer after making string lib
This commit is contained in:
27
string/docs/modify/substring.md
Normal file
27
string/docs/modify/substring.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# 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"
|
||||
```
|
||||
Reference in New Issue
Block a user