Skip to content

Commit

Permalink
Array example Caesar isn't well suited #227: add more hints on how to…
Browse files Browse the repository at this point in the history
… solve the exercise by explaining array operations in more detail.
  • Loading branch information
stonemaster committed Jun 17, 2016
1 parent 1f7c00a commit 69330f8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions public/content/en/basics/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,18 @@ arrays can be created easily using the `auto arr = new int[3][3]` syntax.
#### Array operations and properties

Arrays can be concatenated using the `~` operator which
will create a new dynamic array. Mathematical operations can
be applied to whole arrays using the `c[] = a[] + b[]` syntax.
will create a new dynamic array.

Mathematical operations can
be applied to whole arrays using the `c[] = a[] + b[]` syntax,
which for example adds all elements of `a` and `b` so that
`c[0] = a[0] + b[0]`. `c[1] = a[1] + b[1]` etc. It is also possible
to perform operations on a whole array with a single
value:

a[] *= 2; // multiple all elements by 2
a[] %= 26; // calculate the modulo by 26 for all a's

Those operations might be optimized
by the compiler to use special processors instructions that
do the operations in one go.
Expand Down

0 comments on commit 69330f8

Please sign in to comment.