Foundation of Go Language —— 07. if (Not translated)
»
    Go语言中的条件判断也使用if-else,但是,Go语言中if判断句可以有两个,其中,后面的一个语句起作用:
    if _, exists := book_id_map['Route of go learning']; exists {//book_id_map为map[string]int
        fmt.Println('Exists. this book's id is ' + book_id_map['Route of go learning'])
    } else {
        fmt.Println('Not Exists')
    }

    以上的代码也可以用下面的代码代替,这是if语句中的相同用法:
    if id, exists := book_id_map['Route of go learning']; exists {//book_id_map为map[string]int
        fmt.Println('Exists. this book's id is ' + id)
    } else {
        fmt.Println('Not Exists')
    }
    ————www.v-signon.com学习者共勉
                        
«
--Alex.Zhang
--www.v-signon.com Learningers Co-Encouraged
Back
Personal Art: www.up-task.com Unit: Individual
中文 Русский 京ICP备19038994号-2
If the content on this website infringes upon your any rights, please contact me at 1307776259@qq.com for removal