6. Variables

Source: Internet
Author: User

Use the VaR keyword to declare a group of variables.

In the function parameter, declare the change and put the type to the end.

 
1Package main
2
3 Import "FMT"
4
5VaR x, y, z int
6VaR C, Python, Java bool
7
8Func main (){
9FMT. println (X, Y, Z, C, Python, Java)
10}
 
0 0 0 false False false

Variables declared using the VaR keyword can be none of the initialization values.

If an initialization value exists, the type of each variable can be omitted. It automatically determines the type based on the initial value type.

1Package main
2
3 Import "FMT"
4
5VaR x, y, z Int = 1, 2, 3
6VaR C, Python, Java = true, false,"No!"
7
8Func main (){
9FMT. println (X, Y, Z, C, Python, Java)
10}
 
1 2 3 true false no!

In a function, you can use the: = value assignment statement instead of VaR to hide declarations of the type.

In addition to the function, no build can start with: =.

 
1Package main
2
3 Import "FMT"
4
5Func main (){
6VaR x, y, z Int = 1, 2, 3
7C, Python, Java: = true, false,"No!"
8
9FMT. println (X, Y, Z, C, Python, Java)
10}
 
1 2 3 true false no!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.