Hi,
I would like to understand why below code gives the output as 7 7 7 :
- package main
- import “fmt”
- const (
- i = 7
- j
- k
- )
- func main() {
- fmt.Println(i, j, k)
- }
Hi,
I would like to understand why below code gives the output as 7 7 7 :
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.