Merge "document the behavior of negative substring len" into main

This commit is contained in:
Charles Hall
2025-02-17 21:48:39 +00:00
committed by Gerrit Code Review
+10 -4
View File
@@ -5,12 +5,18 @@ args: [start, len, s]
Return the substring of *s* from character position *start*
(zero-based) up to but not including *start + len*. If *start* is
greater than the length of the string, an empty string is returned,
and if *start + len* lies beyond the end of the string, only the
substring up to the end of the string is returned. *start* must be
non-negative. For example,
and if *start + len* lies beyond the end of the string or *len*
is negative, only the substring up to the end of the string is
returned. *start* must be non-negative. For example,
```nix
builtins.substring 0 3 "nixos"
```
evaluates to `"nix"`.
evaluates to `"nix"`, and
```nix
builtins.substring 3 (-1) "nixos"
```
evaluates to `"os"`.