Created
September 16, 2015 08:53
-
-
Save PyYoshi/eaaf5907dc81ea052faf to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
func 後藤(i int) { | |
fmt.Println("Q: 後藤さんは何匹でしょう?") | |
if i == 1 { | |
goto STATUS1 | |
} else if i == 2 { | |
goto STATUS2 | |
} else { | |
goto OTHER | |
} | |
STATUS1: | |
fmt.Println("A: 後藤さんは1匹") | |
return | |
STATUS2: | |
fmt.Println("A: 後藤さんは2匹") | |
return | |
OTHER: | |
fmt.Printf("A: 後藤さんは%d匹\n", i) | |
return | |
} | |
func main() { | |
後藤(1) | |
後藤(2) | |
後藤(3) | |
// gotoを利用するなら関数で分けてreturnで止めるやり方がいいと思う | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment