varswithinit.go 438 B

12345678910111213141516
  1. // Variables with initializers
  2. package examples
  3. import "fmt"
  4. // A var declaration can include initializers, one per variable.
  5. var i, j int = 1, 2
  6. // VarsWitInit: If an initializer is present, the type can be
  7. // omitted; the variable will take the type of the initializer.
  8. func VarsWithInit() (int, int, bool, bool, string) {
  9. var c, python, java = true, false, "No!"
  10. fmt.Println(i, j, c, python, java)
  11. return i, j, c, python, java
  12. }