@@ -149,18 +149,22 @@ switch List.tailExn(list{}) {
149149let tailExn : list <'a > => list <'a >
150150
151151/**
152- `tailOrThrow(list)` same as [`tail`](#tail).
153- Raises an Error if list is empty.
152+ `tailOrThrow(list)` same as [`tail`](#tail).
154153
155- ## Examples
156- ```res
157- List.tailOrThrow(list{1, 2, 3})->assertEqual(list{2, 3})
154+ ## Examples
155+
156+ ```rescript
157+ List.tailOrThrow(list{1, 2, 3})->assertEqual(list{2, 3})
158158
159- switch List.tailOrThrow(list{}) {
160- | _ => Console.log("never happens")
161- | exception _ => Console.log("error")
162- }
163- ```
159+ switch List.tailOrThrow(list{}) {
160+ | exception Not_found => assert(true)
161+ | _ => assert(false)
162+ }
163+ ```
164+
165+ ## Exceptions
166+
167+ - Raises an Error if list is empty.
164168*/
165169let tailOrThrow : list <'a > => list <'a >
166170
@@ -219,19 +223,26 @@ switch abc->List.getExn(4) {
219223let getExn : (list <'a >, int ) => 'a
220224
221225/**
222- `getOrThrow(list, index)` same as [`get`](#get).
223- Raises an Error if `index` is larger than the length of list.
226+ `getOrThrow(list, index)` same as [`get`](#get).
227+
228+ ## Examples
224229
225- ## Examples
226- ```res
227- let abc = list{"A", "B", "C"}
228- abc->List.getOrThrow(1)->assertEqual("B")
230+ ```rescript
231+ let abc = list{"A", "B", "C"}
229232
230- switch abc->List.getOrThrow(4) {
231- | _ => Console.log("never happens")
232- | exception _ => Console.log("error")
233- }
234- ```
233+ abc
234+ ->List.getOrThrow(1)
235+ ->assertEqual("B")
236+
237+ switch abc->List.getOrThrow(4) {
238+ | exception Not_found => assert(true)
239+ | _ => assert(false)
240+ }
241+ ```
242+
243+ ## Exceptions
244+
245+ - Raises an Error if `index` is larger than the length of list.
235246*/
236247let getOrThrow : (list <'a >, int ) => 'a
237248
0 commit comments