4 ms·
The problem with using the positional method is that 1) It's much more difficult to read since you have to know the position of elements of the struct 2) You
by rifung 7y ago
The problem with using the positional method is that
1) It's much more difficult to read since you have to know the position of elements of the struct
2) You swap one compile time error for another: in the case you add and remove a field of the same type, it's entirely possible the program will compile fine if you use the positional initialization instead of the named one.
#2 makes me think that the author would still be unsatisfied
- throwaway34241 7y ago> It's much more difficult to read since you have to know the position of elements of the struct At least the Go editor I use (GoLand by JetBrains, one of the more popular ones) will display the names of all the fields in positional initializers inline with the code (just as they would be in a named initializer), so it's pretty much the same readability-wise. There's a special color for these automatic labels that indicates they aren't actually part of the document. > in the case you add and remove a field of the same type, it's entirely possible the program will compile fine True although I think it's easier to work around this (by fixing the compile errors from removing the old field before adding the new one).