Last active
August 29, 2015 14:14
-
-
Save giwa/7814a348ef8142f5212d to your computer and use it in GitHub Desktop.
Go by Example: Values ref: http://qiita.com/giwa@github/items/42453354159eb4638df3
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" | |
func main() { | |
// Stringsは+で足すことができる。 | |
fmt.Println("go" + "lang") | |
// intgers と float | |
fmt.Println("1+1 =", 1+1) | |
fmt.Println("7.0/3.0 =", 7.0/3.0) | |
// Booleansとあなたがいつも使っているようなオペレータ | |
fmt.Println(true && false) | |
fmt.Println(true || false) | |
fmt.Println(!true) | |
} | |
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" | |
func main() { | |
// Stringsは+で足すことができる。 | |
fmt.Println("go" + "lang") | |
// intgers と float | |
fmt.Println("1+1 =", 1+1) | |
fmt.Println("7.0/3.0 =", 7.0/3.0) | |
// Booleansとあなたがいつも使っているようなオペレータ | |
fmt.Println(true && false) | |
fmt.Println(true || false) | |
fmt.Println(!true) | |
} | |
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
$ go run values.go | |
golang | |
1+1 = 2 | |
7.0/3.0 = 2.3333333333333335 | |
false | |
true | |
false | |
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" | |
func main() { | |
// int / int | |
fmt.Println("1/3 =", 1/3) | |
// int / float | |
fmt.Println("1/3.0 =", 1/3.0) | |
} |
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
$ go run int-float.go | |
1/3 = 0 | |
1/3.0 = 0.3333333333333333 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment