* Henry [210810 01:26]:
> Just sharing some tips.
>
> When working with slices, it is often a good idea to lend a helping hand to
> the compiler.
>
> Don't declare something like this, unless you have no other choices.
> ```
> var slice []int
> ```
I believe this is bad advice.
First, if «sl
Just sharing some tips.
When working with slices, it is often a good idea to lend a helping hand to
the compiler.
Don't declare something like this, unless you have no other choices.
```
var slice []int
```
If you know the data right away, you can do something like this:
```
slice := []int{1,2,
Thanks, Brain. It is absolutely fantastic. I saw this SliceTricks two days
ago. Nice to mention it.
On Sunday, August 8, 2021 at 8:36:27 PM UTC+4:30 Brian Candler wrote:
> On Friday, 6 August 2021 at 18:00:35 UTC+1 Konstantin Khomoutov wrote:
>
>> Have you read and understood [1] and [2]?
>>
>
Henry Thanks for your time,
You're right. Sounds reasonable. But you know, the first time I saw this
thing, I was like, when I pass the new slice to my existing slice, does it
not replace the item in the same address in memory that my slice has
before?
Because when I pass new data to my variabl
Thank you, Konstantin. I really appreciate your response, I didn't read
those links before you sent them to me, but I read them yesterday, now
everything is so clear to me, and I know what is going on with "slice,"
"append," and "copy" in memory.
I was so confused, but now I know what's going on
On Friday, 6 August 2021 at 18:00:35 UTC+1 Konstantin Khomoutov wrote:
> Have you read and understood [1] and [2]?
> ...
> 1. https://blog.golang.org/slices-intro
> 2. https://blog.golang.org/slices
>
>
Also possibly of interest (although it doesn't mention rotation):
https://github.com/golang/
Append is for appending items at the end of a slice. If there is enough
space, Go will simply append the items and return the slice. If there is
not enough space, Go will create a new slice with double the capacity of
the existing slice or at least enough space to hold the new items
(whichever
On Fri, Aug 06, 2021 at 12:42:34AM -0700, Miraddo wrote:
Hi!
> I can not understand why when we use append, it does not rewrite values in
> the same address in the memory that it had before,
>
> (I'm not sure it "append" problem or the variable | or just my problem for
> sure :) )
[...]
> I
Hello all,
I can not understand why when we use append, it does not rewrite values in
the same address in the memory that it had before,
(I'm not sure it "append" problem or the variable | or just my problem for
sure :) )
let me explain what I mean,
I solve a question in LeetCode (189. R