zoukankan      html  css  js  c++  java
  • 对一段有关Go Code Block和变量作用域的代码的简要分析 原创 Tony Bai TonyBai 2018-05-11

    对一段有关Go Code Block和变量作用域的代码的简要分析

     

    https://mp.weixin.qq.com/s/vD8jOjkt_kBc9fd8huIUAQ

    Each file has a file block containing all Go source text in that file.

    4. Each "if", "for", and "switch" statement is considered to be in its own implicit block.

    5. Each clause in a "switch" or "select" statement acts as an implicit block.


    func writeDb(Type int) bool {
    var B bool
    switch Type {
    case 1:
    B = true

    }
    return B
    }

    type T struct {
    B bool
    }

    func writeDb1(Type int) (t T) {
    var B bool
    switch Type {
    case 1:
    B = true
    }
    t.B = B
    return
    }

    func main() {

    i := writeDb(1)


    j := writeDb(2)

    i1 := writeDb1(1)


    j1 := writeDb1(2)

    fmt.Println(i,j,i1,j1)

  • 相关阅读:
    [转]进程间通信----pipe和fifo
    [转]udev
    [转]netlink
    [转]进程间通信-----管道
    [转]socket
    [转]armv8 memory system
    [转]内核态和用户态
    [转]dpdk内存管理
    meeting and robert rules
    notion
  • 原文地址:https://www.cnblogs.com/rsapaper/p/14542827.html
Copyright © 2011-2022 走看看