You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Printing is handled by various I/O stream functions. One should know where to use them accordingly.
6
+
7
+
-`print`: for printing the text to the output stream without a newline.
8
+
9
+
-`println`: same as `print` but newline appended automatically.
10
+
11
+
-`eprint`: same as `print` but the output goes to error stream (stderr).
12
+
13
+
-`eprintln`: same as `println` but the output goes to error stream (stderr).
14
+
15
+
-`panic`: outputs and exits from the program.
16
+
17
+
```go
18
+
print('Hello World')
19
+
print('Hello V')
20
+
```
21
+
22
+
This will print `Hello WorldHello V`
23
+
24
+
If you want to print the next line on a new line you would have to do `\n`.
25
+
```go
26
+
print('Hello World \n')
27
+
print('Hello V ')
28
+
```
29
+
If you don't want to use `\n` then you can use `println` instead.
30
+
31
+
## Comments
32
+
33
+
V supports single line comments `//` and mutli-line comments `/* */`. They should be used for documenting the code for letting the other users know how the code works. It can also be used for temporarily commenting the code which has to be used later on.
34
+
35
+
```go
36
+
// This is a single line comment
37
+
38
+
/* This is a
39
+
* multi-line comment
40
+
* /* This could be nested as well*/
41
+
*/
42
+
```
43
+
44
+
## Exercises
45
+
46
+
Try uncommenting the code in `hello.v` and see what happens.
0 commit comments