git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Update syntax.rst
commit9f12202c714433da33937113c3d2538023a549cf authorPhil Freeman <paf31@cantab.net> dateWed 23 Apr 2014, 22:22 (13 years ago) parent6031831
1 file changed+5−3
docs/source/syntax.rst+5−3
docs/source/syntax.rst+5−3
@@ -95,11 +95,13 @@ Record literals are surrounded by braces, as in Javascript::
9595Array Indexing
9696--------------
9797
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::
9999
100− arr !! 0
100+ unsafeIndex :: forall a. [a] -> Number -> a
101101
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``.
103105
104106Property Accessors
105107------------------