Wanted to understand more about Const


I would like to understand why below code gives the output as 7 7 7 :

  1. package main
  2. import “fmt”
  3. const (
  4. i = 7
  5. j
  6. k
  7. )
  8. func main() {
  9. fmt.Println(i, j, k)
  10. }

because if the type/value is not specified for the constant, it will be taken from the previous constant.

I tried searching documentation for the same but could not find it. I did read about iota but for that we need to have iota while assigning value. Please can you share documentation link if possible.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.