You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/@rescript/runtime/Belt.res
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ One common confusion comes from the way Belt handles array access. It differs fr
99
99
let letters = ["a", "b", "c"]
100
100
let a = letters[0] // a == "a"
101
101
let capitalA = Js.String.toUpperCase(a)
102
-
let k = letters[10] // Raises an exception! The 10th index doesn't exist.
102
+
let k = letters[10] // Throws an exception! The 10th index doesn't exist.
103
103
```
104
104
105
105
Because Belt avoids exceptions and returns `options` instead, this code behaves differently:
@@ -114,7 +114,7 @@ let captialA = Js.String.toUpperCase(a) // Type error! This code will not compil
114
114
let k = letters[10] // k == None
115
115
```
116
116
117
-
Although we've fixed the problem where `k` raises an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here:
117
+
Although we've fixed the problem where `k` throws an exception, we now have a type error when trying to capitalize `a`. There are a few things going on here:
118
118
119
119
- Reason transforms array index access to the function `Array.get`. So `letters[0]` is the same as `Array.get(letters, 0)`.
120
120
- The compiler uses whichever `Array` module is in scope. If you `open Belt`, then it uses `Belt.Array`.
0 commit comments