git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update syntax.rst
9f12202Phil Freeman
docs/source/syntax.rst+5−3
@@ -95,11 +95,13 @@ Record literals are surrounded by braces, as in Javascript::
95Array Indexing
95Array Indexing
96--------------
96--------------
97
97
98−To retrieve the element of an array at an index, use the ``!!`` operator::
98+The ``Prelude.Unsafe`` module defines the ``unsafeIndex`` function which retrieves the element of an array at an index::
99
99
100− arr !! 0
100+ unsafeIndex :: forall a. [a] -> Number -> a
101
101
102−This example corresponds to the Javascript ``arr[0]``.
102+The code generator will turn the expression ``unsafeIndex arr index`` into the simplified Javascript ``arr[index]``.
103+
104+The `purescript-array` core library defines an alternative safe version ``!!`` of ``unsafeIndex`` which checks arrays bounds and returns a value of type ``Maybe a``.
103
105
104Property Accessors
106Property Accessors
105------------------
107------------------