Add docs to List.get with example

This commit is contained in:
HajagosNorbert 2023-06-11 17:56:56 +02:00
parent 79e9ba3dd1
commit 232e9030ae
No known key found for this signature in database
GPG key ID: 807F4444870DB673

View file

@ -222,6 +222,13 @@ isEmpty = \list ->
# but will cause a reference count increment on the value it got out of the list
getUnsafe : List a, Nat -> a
## Returns an element from a list at the given index.
##
## Returns `Err OutOfBounds` if the given index exceeds the List's length
## ```
## expect List.get [100, 200, 300] 1 == Ok 200
## expect List.get [100, 200, 300] 5 == Err OutOfBounds
## ```
get : List a, Nat -> Result a [OutOfBounds]
get = \list, index ->
if index < List.len list then