doc: list more builtin functions with better description of each (#7587)
parent
712bacab98
commit
ba48cf3238
30
doc/docs.md
30
doc/docs.md
|
@ -1619,9 +1619,23 @@ are no globals:
|
|||
println('Top cities: $top_cities.filter(.usa)')
|
||||
```
|
||||
|
||||
## println and other builtin functions
|
||||
## Builtin functions
|
||||
|
||||
`println` is a simple yet powerful builtin function. It can print anything:
|
||||
Some functions are builtin like `println`. Here is the complete list:
|
||||
|
||||
```v ignore
|
||||
fn print(s string) // print anything on sdtout
|
||||
fn println(s string) // print anything and a newline on sdtout
|
||||
|
||||
fn eprint(s string) // same as print(), but use stderr
|
||||
fn eprintln(s string) // same as println(), but use stderr
|
||||
|
||||
fn exit(code int) // terminate the program with a custom error code
|
||||
fn panic(s string) // print a message and backtraces on stderr, and terminate the program with error code 1
|
||||
fn print_backtrace() // print backtraces on stderr
|
||||
```
|
||||
|
||||
`println` is a simple yet powerful builtin function, that can print anything:
|
||||
strings, numbers, arrays, maps, structs.
|
||||
|
||||
```v nofmt
|
||||
|
@ -1654,18 +1668,6 @@ red := Color{
|
|||
println(red)
|
||||
```
|
||||
|
||||
If you don't want to print a newline, use `print()` instead.
|
||||
|
||||
The number of builtin functions is low. Other builtin functions are:
|
||||
|
||||
|
||||
```v ignore
|
||||
fn exit(exit_code int) // terminate the program
|
||||
fn panic(message string)
|
||||
fn print_backtrace()
|
||||
fn eprintln(s string) // same as println, but use stderr
|
||||
```
|
||||
|
||||
## Modules
|
||||
|
||||
Every file in the root of a folder is part of the same module.
|
||||
|
|
Loading…
Reference in New Issue