-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add an example with automatic array size #522
Conversation
You can learn more about this here: https://go.dev/blog/slices-intro#arrays
Forgot about this file 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thank you! Some comments before we proceed
fmt.Println("dcl:", b) | ||
|
||
// If you specify the index with `:`, the elements in | ||
// between will be zeroed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is a good place to add that the array length is the maximum index plus one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that information would add much value since gobyexample is meant for people who already have experience in other programming languages and the length of a list is always the maximum index plus one everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I mean it specifically in the context of the [...]
syntax with explicitly specifying indeces. For example in your second b
with the 3:
, the array length is 5 because of that.
I don't feel strongly about this, though.
I've noticed a file called arrays.hash. What is that for? Do I also have to update it? |
You don't need to do it manually, you should run |
I assumed these kind of things were made automatically by a CI/CD pipeline of some sort, as most people do. I'll run the script and commit the result, but I think you should consider creating a Github Action workflow or something instead. EDIT: Hold on, you actually have that, but you use it to test the result and make sure I ran the script. Why though? Can't you just use the result of running that script automatically instead? |
The output in |
You can learn more about this here: https://go.dev/blog/slices-intro#arrays