1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: helping V to determine an array type

This commit is contained in:
sudo-nice 2020-06-17 13:03:09 +03:00 committed by GitHub
parent fb5cae7376
commit 5749add670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -425,7 +425,9 @@ The type of an array is determined by the first element: `[1, 2, 3]` is an array
`['a', 'b']` is an array of strings (`[]string`).
V arrays are homogenous (all elements must have the same type). This means that code like `[1, 'a']` will not compile.
If V is unable to infer the type of an array, the user can explicitly specify it for the first element: `[byte(0x0E), 0x1F, 0xBA, 0x0E]`
V arrays are homogeneous (all elements must have the same type). This means that code like `[1, 'a']` will not compile.
`<<` is an operator that appends a value to the end of the array.
It can also append an entire array.