执行下列代码的输出结果为(    ...
发布于 2022-03-03 11:34:17
执行下列代码的输出结果为( )
package main
type S struct{}
func (s S) F() {}
type IF interface {
F()
}
func InitType() S {
var s S
return s
}
func InitPointer() *S {
var s *S
return s
}
func InitEfaceType() interface{} {
var s S
return s
}
func InitEfacePointer() interface{} {
var s *S
return s
}
func InitIfaceType() IF {
var s S
return s
}
func InitIfacePointer() IF {
var s *S
return s
}
func main() {
println(InitType() == nil)
println(InitPointer() == nil)
println(InitEfaceType() == nil)
println(InitEfacePointer() == nil)
println(InitIfaceType() == nil)
println(InitIfacePointer() == nil)
}
package main
type S struct{}
func (s S) F() {}
type IF interface {
F()
}
func InitType() S {
var s S
return s
}
func InitPointer() *S {
var s *S
return s
}
func InitEfaceType() interface{} {
var s S
return s
}
func InitEfacePointer() interface{} {
var s *S
return s
}
func InitIfaceType() IF {
var s S
return s
}
func InitIfacePointer() IF {
var s *S
return s
}
func main() {
println(InitType() == nil)
println(InitPointer() == nil)
println(InitEfaceType() == nil)
println(InitEfacePointer() == nil)
println(InitIfaceType() == nil)
println(InitIfacePointer() == nil)
}
登录后免费查看答案
关注者
0
被浏览
12