Skip to content

Instantly share code, notes, and snippets.

@nobishino
Last active August 5, 2020 23:31
Show Gist options
  • Save nobishino/b6c03595ee852d01815a9286425c902c to your computer and use it in GitHub Desktop.
Save nobishino/b6c03595ee852d01815a9286425c902c to your computer and use it in GitHub Desktop.
Quizground-2.go
package main
import "fmt"
type T struct {
x int
}
func (t *T) Set(x int) {
t.x = x
}
type S struct {
T
}
func main() {
s := S{}
s.Set(1)
fmt.Println(s.x)
}
// playgroundで試したい方は https://play.golang.org/p/zkY6RCDPTZT
// (1) compile error(build error)
// (2) runtime error
// (3) 1と表示される
// (4) 0と表示される
// 解説リンクは(自分が理解出来次第)追加されます
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment