Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GO] Change count of elements wherever ellipsis is used #2700

Closed
antimatter96 opened this issue Apr 7, 2017 · 3 comments
Closed

[GO] Change count of elements wherever ellipsis is used #2700

antimatter96 opened this issue Apr 7, 2017 · 3 comments

Comments

@antimatter96
Copy link

So this is a really dumb request but while reading I thought that ... (ellipsis) represented the size of the array in Line 2 below.
Given how there are three dots as well as three elements it would be better if we change the size so that confusion is avoided.
Not everyone knows what ellipsis are 😢

1. var a4 [4]int           // An array of 4 ints, initialized to all 0.
2. a3 := [...]int{3, 1, 5} // An array initialized with a fixed size of three**
// elements, with values 3, 1, and 5.


// Slices have dynamic size. Arrays and slices each have advantages
// but use cases for slices are much more common.
3. s3 := []int{4, 5, 9}    // Compare to a3. No ellipsis here.
4. s4 := make([]int, 4)    // Allocates slice of 4 ints, initialized to all 0.
5. var d2 [][]float64      // Declaration only, nothing allocated here.
6. bs := []byte("a slice") // Type conversion syntax.

PROPOSED CAHNGES

1. var a4 [4]int           // An array of 4 ints, initialized to all 0.
2. a3 := [...]int{3, 1, 5, 7} // An array initialized with a fixed size of three** --CHANGED--
// elements, with values 3, 1, and 5.

// Slices have dynamic size. Arrays and slices each have advantages
// but use cases for slices are much more common.
3. s3 := []int{4, 5, 9, 7}    // Compare to a3. No ellipsis here.  --CHANGED--
4. s4 := make([]int, 4)    // Allocates slice of 4 ints, initialized to all 0.
5. var d2 [][]float64      // Declaration only, nothing allocated here.
6. bs := []byte("a slice") // Type conversion syntax.
@adambard
Copy link
Owner

Good change! Just to check, a3 := [...]int{3, 1, 5, 7} creates an array with a size of four, correct?

@antimatter96
Copy link
Author

antimatter96 commented Apr 12, 2017

Yes. Count of dots do not matter ( as long as there as three).
I am guessing the same issue might be in multiple languages

@antimatter96
Copy link
Author

@adambard any headway ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants