aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Jean Johansen <mathias@mjj.io>2022-05-02 17:08:53 +0200
committerLouis Pilfold <louis@lpil.uk>2022-05-04 22:08:15 +0100
commit215a4868d237d349aeae9e033ed907ac6313bee0 (patch)
treedcd58484f788840416d421ae5044f43b48912fc5
parente85d977985e48dd5f76db564ee8e978a3118bb20 (diff)
downloadgleam_stdlib-215a4868d237d349aeae9e033ed907ac6313bee0.tar.gz
gleam_stdlib-215a4868d237d349aeae9e033ed907ac6313bee0.zip
Replace `length` with negative index.
-rw-r--r--src/gleam/string.gleam2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/gleam/string.gleam b/src/gleam/string.gleam
index d574242..6c58135 100644
--- a/src/gleam/string.gleam
+++ b/src/gleam/string.gleam
@@ -782,7 +782,7 @@ pub fn first(s: String) -> Option(String) {
pub fn last(s: String) -> Option(String) {
case length(s) {
0 -> None
- _ -> Some(slice(s, length(s) - 1, 1))
+ _ -> Some(slice(s, -1, 1))
}
}