当前位置:网站首页>[Yugong series] go teaching course 005 variables in July 2022
[Yugong series] go teaching course 005 variables in July 2022
2022-07-07 04:53:00 【InfoQ】
One 、 Variable
1. Definition of variables
2. Role of variables
3. Variable declaration and initialization
3.1 Declaration of variables
fmt.Println(a)
3.2 Initialization of a variable
var age int=10
3.3 The assignment of a variable
var age,num int
age=10
num=20
fmt.Println(age,num) //10,20
var age int =10
var num int
num=age
fmt.Println(num) //10
3.4 Case study : Exchange the values of two variables
package main
import "fmt"
func main(){
a := 1
b := 5
var t int
t = a
a = b
b = t
fmt.Println("a = ", a, "b = ", b )
}
package main
import "fmt"
func main(){
a := 1
b := 5
a = a + b
b = a - b
a = a - b
fmt.Println("a = ", a, "b = ", b )
}
package main
import "fmt"
func main() {
a := []int{1, 2}
b := []int{3, 4, 5}
a, b = b, a
fmt.Println(`a:`, a)
fmt.Println(`b:`, b)
}
summary
- Variable declarations :var Variable name variable type
- Declare multiple variables :var Variable name 1, Variable name .... type
- Declare an integer variable , The default value is 0
- Output statements can use only one Println function , The middle part is separated by English half width commas !
- You can set the value of a variable , Assign to another variable , And the old value in the variable is overwritten by the new value .
边栏推荐
- Jetson nano configures pytorch deep learning environment / / to be improved
- 九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
- 《原动力 x 云原生正发声 降本增效大讲堂》第三讲——Kubernetes 集群利用率提升实践
- Canteen user dish relationship system (C language course design)
- Common methods of list and map
- You can't sell the used lithography machine to China! The United States unreasonably pressured the Dutch ASML, and domestic chips were suppressed again
- JS variable
- MySQL split method usage
- JS variable plus
- B站大佬用我的世界搞出卷积神经网络,LeCun转发!爆肝6个月,播放破百万
猜你喜欢
System framework of PureMVC
Vscode 如何使用内置浏览器?
Case reward: Intel brings many partners to promote the innovation and development of multi domain AI industry
R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
Intel David tuhy: the reason for the success of Intel aoten Technology
Section 1: (3) logic chip process substrate selection
acwing 843. N-queen problem
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
Programmers go to work fishing, so play high-end!
【实践出真理】import和require的引入方式真的和网上说的一样吗
随机推荐
Read of shell internal value command
食堂用户菜品关系系统(C语言课设)
How does vscade use the built-in browser?
Is there any way to bookmark the code in the visual studio project- Is there a way to bookmark code in a Visual Studio project?
offer如何选择该考虑哪些因素
Factor analysis r practice (with R installation tutorial and code)
What is Web3
广告归因:买量如何做价值衡量?
什么是Web3
Leetcode notes
leetcode 53. Maximum subarray maximum subarray sum (medium)
Two methods of chromosome coordinate sequencing
AI landing new question type RPA + AI =?
Introduction to the PureMVC series
组织实战攻防演练的5个阶段
JS variable case
If you ask me about R code debugging, I will tell you head, STR, help
JS variable
Intel and Xinbu technology jointly build a machine vision development kit to jointly promote the transformation of industrial intelligence
Depth first traversal template principle of tree and graph