From 69330f826170de1c4f792760bf2a0d521400acc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Stein?= Date: Fri, 17 Jun 2016 19:43:48 +0200 Subject: [PATCH] Array example Caesar isn't well suited #227: add more hints on how to solve the exercise by explaining array operations in more detail. --- public/content/en/basics/arrays.md | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/public/content/en/basics/arrays.md b/public/content/en/basics/arrays.md index 7723ae6a..1b04a5c9 100644 --- a/public/content/en/basics/arrays.md +++ b/public/content/en/basics/arrays.md @@ -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.