Skip to content

Instantly share code, notes, and snippets.

@giwa
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giwa/7814a348ef8142f5212d to your computer and use it in GitHub Desktop.
Save giwa/7814a348ef8142f5212d to your computer and use it in GitHub Desktop.
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)
}
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)
}
$ go run values.go
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false
package main
import "fmt"
func main() {
// int / int
fmt.Println("1/3 =", 1/3)
// int / float
fmt.Println("1/3.0 =", 1/3.0)
}
$ 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