summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMilo Gilad <milogaccnts@gmail.com>2017-08-25 07:46:56 -0400
committerMilo Gilad <milogaccnts@gmail.com>2017-08-25 07:46:56 -0400
commit8db305354698abed7c87b14e4958fb8b688cbfb0 (patch)
treed5f6de1576b0f62ee63f270a913b414f75fe8ef9
parent0c105ca0b23f5e5d83876d216be6a4812425954b (diff)
Added more on arrays
-rwxr-xr-xvala.html.markdown10
1 files changed, 10 insertions, 0 deletions
diff --git a/vala.html.markdown b/vala.html.markdown
index a8d90e47..a296fe9e 100755
--- a/vala.html.markdown
+++ b/vala.html.markdown
@@ -67,6 +67,8 @@ stderr.printf("Error message"); // Error printing
/* Arrays */
int[] int_array = new int[10]; // Array of ints with 10 slots
+int_array.length; // => 10;
+
int[] int_array2 = {5, 10, 15, 20}; // Can be created on-the-fly
int[] array_slice = int_array2[1:3]; // Slice (copy of data)
@@ -79,6 +81,14 @@ int[,] multi_array2 = {{7, 4, 6, 4},
{3, 2, 4, 6},
{5, 9, 5, 1}};
multi_array2[2,3] = 12; // 2 is the array, 3 is the index in the array
+int first_d = multi_array2.length[0] // => 3
+int second_d = multi_array2.length[1] // => 4
+
+// Stacked arrays (e.g. int[][]) where array lengths vary are not supported.
+
+// Multi-dimensional arrays cannot be sliced, nor can they be converted to one-
+// dimensional.
+
struct Closet {
public uint shirts;