Last active
September 30, 2017 12:08
-
-
Save spiegel-im-spiegel/0df765396332f30cb80ca9a735019180 to your computer and use it in GitHub Desktop.
クラスとオブジェクトの関係性(Go 言語編) ref: http://qiita.com/spiegel-im-spiegel/items/2da5e5902aa2cb6d9e30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Taiyaki | |
def atama | |
puts "たい焼きの頭の方にはあんこがいっぱい入っている" | |
end | |
def shippo | |
puts "たい焼きの尻尾にはあんこがほとんど入っていない" | |
puts "しかしカリカリしていて美味しい" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Taiyaki struct{} | |
func (t Taiyaki) Atama() { | |
fmt.Println("たい焼きの頭の方にはあんこがいっぱい入っている") | |
} | |
func (t Taiyaki) Shippo() { | |
fmt.Println("たい焼きの尻尾にはあんこがほとんど入っていない") | |
fmt.Println("しかしカリカリしていて美味しい") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taiyakikun_1gou = Taiyaki.new | |
taiyakikun_2gou = Taiyaki.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var taiyakikun1gou Taiyaki | |
var taiyakikun2gou Taiyaki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var taiyakikun1gou, taiyakikun2gou Taiyaki |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taiyakikun1gou := new(Taiyaki) | |
taiyakikun2gou := new(Taiyaki) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taiyakikun1gou := &Taiyaki{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func New() *Taiyaki { | |
return &Taiyaki{} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type Taiyaki struct{} | |
func (t Taiyaki) Atama() { | |
fmt.Println("たい焼きの頭の方にはあんこがいっぱい入っている") | |
} | |
func (t Taiyaki) Shippo() { | |
fmt.Println("たい焼きの尻尾にはあんこがほとんど入っていない") | |
fmt.Println("しかしカリカリしていて美味しい") | |
} | |
func main() { | |
var taiyakikun1gou Taiyaki | |
taiyakikun1gou.Atama() | |
taiyakikun1gou.Shippo() | |
var taiyakikun2gou Taiyaki | |
taiyakikun2gou.Atama() | |
taiyakikun2gou.Shippo() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment