err := rpc.RegisterName("hello", new(Hello)) lisening, err := 1,rpc.RegisterName("hello", new(Hello)) 2次err的作用域是否一样
err := rpc.RegisterName("hello", new(Hello)) lisening, err := 1,rpc.RegisterName("hello", new(Hello)) 2次err的作用域是否一样
err := rpc.RegisterName("hello", new(Hello)) lisening, err := 1,rpc.RegisterName("hello", new(Hello)) 2次err的作用域是否一样

张家俊
2025年02月04日
|
浏览 154
作用域不一样。第一个 err 变量是在函数调用时声明的,其作用域只在该函数内部有效;而第二个 err 变量是在赋值操作时声明的,其作用域只在该赋值语句之后的代码块内有效。因此,这两个 err 变量的作用域是不同的。
我要提问
复制内容
分享给好友
AI编程问答网 免责声明:
以上内容除特别注明外均来源于网友提问,AI编程问答网回答,权益归原著者所有;
