"Go Learning Notes" 4, constants and operators

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Definition of constants

    • The value of the constant is determined at compile time
    • Constants are defined in the same format as variables
    • The right side of the equal sign must be a constant or constant expression
    • A function in a constant expression must be a built-in function
1234567891011121314
Const int 1 Const ' A ' Const "123" Len ) Const 1,"2","3"const"234",len)

Initialization rules and enumerations for constants

    • When you define a constant group, if you do not provide an initial value, the expression that will use the upstream
    • Using the same expression does not mean that you have the same value
    • Iota is a constant counter, starting with 0, the group does not define 1 constants automatically incremented by 1
    • The effect of enumerations can be achieved by initializing rules with iota
    • Without encountering a const keyword, iota resets to 0
12345678910111213141516171819
Const "A" Iota //d = = 3) Const Iota //f = = 1) Const Iota Tuesdaywednesday ....)

Operator

Operators in Go are combined from left to right, with precedence (high to low)
^ !
*/% << >> & &^
+ - | ^
= = = < <= >= >
<-
&&
||

 1234567 
 6 : 0110  11 : 1011 -------------& 0010  | 1111  ^ 1101  
Related Article

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.