Skip to content

Fixed hello, and added consts #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion en/examples/section_1/hello_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ It can also be used for temporarily commenting the code which has to be used lat

## Exercises

Try uncommenting the code in `hello.v` and see what happens.
Try uncommenting the code in `code/hello.v` and see what happens.
99 changes: 99 additions & 0 deletions en/examples/section_1/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,102 @@ myfamily_number
IamNotValid
new Make
```

# Const

In V variables can be declared a constant and that means non changing by adding the `const` keyword before the variable name.

```go
const my_name = "AxiomApollo" // note we use `=` instead of `:=`
println(my_name)
const language = english
println(language)
```
>Note: const can only be defined at the module level (outside of functions)

You can declare multiple constants in one const expression

```go
const (
pi = 3.14159
is_reading = true
)
```

## Naming Rules

The following are the rules which should be kept in mind while naming consts.

- Name should not contain Uppercase letters like `AlphaTest`
- Use underscores as separators like `hello_world`
- Name should be descriptive as possible
- Name should not contain `__`
- Name should not contain any space
- If the name is longer than 11 then it must use `_` as separator

### Valid Names

```go
const (
animals = ["cow","dog","lion"]
red = 255
long_const_name = "Use this."
)
```

### Invalid Names

```go
const (
WRONG = false
longconstname = "avoid this."
)
```
# Const

In V variables can be declared a constant and that means non changing by adding the `const` keyword before the variable name.

```go
const my_name = "AxiomApollo" // note we use `=` instead of `:=`
println(my_name)
const language = english
println(language)
```
>Note: const can only be defined at the module level (outside of functions)

You can declare multiple constants in one const expression

```go
const (
pi = 3.14159
is_reading = true
)
```

## Naming Rules

The following are the rules which should be kept in mind while naming consts.

- Name should not contain Uppercase letters like `AlphaTest`
- Use underscores as separators like `hello_world`
- Name should not contain `__`
- Name should not contain any space

### Valid Names

```go
const (
animals = ["cow","dog","lion"]
red = 255
long_const_name = "Use this."
)
```

### Invalid Names

```go
const (
WRONG = false
longconstname = "avoid this."
)
```