zoukankan      html  css  js  c++  java
  • 1.go变量

    package main
    
    import "fmt"
    
    func main() {
    	//	Declare variables that are set to their zero value.
    	// 0 值
    	var a int
    	var b string
    	var c float64
    	var d bool
    	fmt.Printf("var a int 	 %T [%v]
    ", a, a)
    	fmt.Printf("var b string 	 %T [%v]
    ", b, b)
    	fmt.Printf("var c float64 	 %T [%v]
    ", c, c)
    	fmt.Printf("var d bool 	 %T [%v]
    ", d, d)
    	/*
    
    		var a int 	 int [0]
    		var b string 	 string []
    		var c float64 	 float64 [0]
    		var d bool 	 bool [false]
    
    	*/
    
    	fmt.Printf("
    ")
    
    	// Declare variables and initialize.
    	// Using the short variable declaration operator.
    	//	 初始值, 使短声明
    	aa := 10
    	bb := "hello"
    	cc := 3.14159
    	dd := true
    
    	fmt.Printf("aa := 10 	 %T [%v]
    ", aa, aa)
    	fmt.Printf("bb := "hello" 	 %T [%v]
    ", bb, bb)
    	fmt.Printf("cc := 3.14159 	 %T [%v]
    ", cc, cc)
    	fmt.Printf("dd := true 	 %T [%v]
    ", dd, dd)
    
    	/*
    		aa := 10 	 int [10]
    		bb := "hello" 	 string [hello]
    		cc := 3.14159 	 float64 [3.14159]
    		dd := true 	 bool [true]
    
    	*/
    
    	//	Specify type and perform a conversion.
    	// 类型转换
    	aaa := int32(10)
    	fmt.Printf("aaa := int32(10) 	 %T [%v]
    ", aaa, aaa)
    	/*
    		aaa := int32(10) 	 int32 [10]
    	*/
    
    }
    
    /*
    	Zero Values:
    	Type Initialized Value
    	Boolean false
    	Integer 0
    	Floating Point 0
    	Complex 0i
    	String "" (empty string)
    	Pointer nil
    */
    

    练习

    // All material is licensed under the Apache License Version 2.0, January 2004
    // http://www.apache.org/licenses/LICENSE-2.0
    
    // Declare three variables that are initialized to their zero value and three
    // declared with a literal value. Declare variables of type string, int and
    // bool. Display the values of those variables.
    //
    // Declare a new variable of type float32 and initialize the variable by
    // converting the literal value of Pi (3.14).
    package main
    
    // main is the entry point for the application.
    func main() {
    
    	// Declare variables that are set to their zero value.
    	var a1 int
    	var b1 string
    	var c1 bool
    
    	// Display the value of those variables.
    	print("a1:", a1, " b1:", b1, " c1:", c1)
    
    	// Declare variables and initialize.
    	// Using the short variable declaration operator.
    	a11 := 111
    	b11 := "what"
    	c11 := true
    
    	// Display the value of those variables.
    	println("a11-->", a11, " b11-->", b11, " c11-->", c11)
    
    	// Perform a type conversion.
    	Pi := float32(3.14)
    
    	// Display the value of that variable.
    	println(Pi)
    }
    
  • 相关阅读:
    background-clip与background-origin
    jquery判断一个元素是否为某元素的子元素
    Math.pow()实现开任意次方根
    vue基础点
    css3
    css系统学习
    angularJs
    jquery与JavaScript
    bootstrapt使用
    bootstrap
  • 原文地址:https://www.cnblogs.com/zrdpy/p/8577056.html
Copyright © 2011-2022 走看看