
Getting Started with V Programming
By :

A string is used to represent words, phrases, or paragraphs of text. It can hold all the alphanumeric characters, special characters, and symbols.
The syntax to declare a variable of string data type is shown here:
<VARIABLE_NAME> := '<TEXT>'
From the preceding syntax, we notice that the variable name to the left of the :=
symbol and value held by the variable is placed to the right. We also notice that the value held by the variable is enclosed in single quotes ('
). V also allows you to declare variables with values enclosed in double quotes ("
).
For example, consider the following code snippet:
h := 'hello' println(h) // hello println(h.len) // 5 typeof(h).name // string
The preceding code demonstrates how to declare a string variable and the usage of the default field named len
, which indicates the length of the string.
There are certain properties related to...