After getting bitten by the subslice-from-slice capacity issue (which felt like a throwback into the 1980s and programming in "C"), I searched for information and came across your Go Class YT series. My compliments for how clear and concise you present the subject matter.
@mattkdvb51543 жыл бұрын
Thanks! Yeah, it would have been better for the two-index slice to fix capacity=length. Sigh.
@unionafrican60942 жыл бұрын
You know what? Since 25 minutes I'm trying to write something to explain what have you done for me but I couldn't. Sir, You're the only one clarify the slice to me.
@bernhardbaumgartner4702 Жыл бұрын
Your KZbin serious is better than many paid courses on other platforms like Udemy or Coursera and stuff. Man, you really have a gift there, especially when it comes to explaining rather complicated issues like the slices/subslices thingy! So far I wasn’t even aware of it. Thanks buddy, highly, highly appreciated!
@srenh-p3798 Жыл бұрын
To anyone, like me, confused by the fmt.Printf() statement at 1:00, which is seemingly missing a parameter. "%#[3]v" is referring to the third parameter following the format string. Which in this case is the slice 's'
@Taddy_Mason9 ай бұрын
Thanks for explaining that, it was bugging me.
@AmirSerati-c5n11 ай бұрын
This video is a must for anyone learning go and generally computer science
@kewtomrao Жыл бұрын
So slices are just pointers + manipulation uisng slice descriptors and abstraction on top of it. The way you showed the slice descriptors makes it very easy to comprehend. Thanks for this amazing tutorial
@LesterFernandezIO Жыл бұрын
I love the technical depth. Awesome video.
@eldarkurm2 жыл бұрын
gold mine of knowledge
@massimo6767 Жыл бұрын
The subslice thing is counterintuitive but it makes sense: b points to a and c points to b which points to a, so the slice operator [n:m] always refers to the same underlying head cell of the array.
@plutackАй бұрын
wouldn't it have been better to be a copy instead of a reference. i get that is how slices are designed cos go does creates a underlying array so a ponter/referenve does makes sense.. i think this ultimately promotes the use of slices rather than arrays for anything
@MixturaLife6 күн бұрын
Was doing advent of code this year, decided to use go to learn it deeper and faced this very strange behaviour So basically never append to or modify values in slices that were derived from array/another slice…😅 Thank you for explanation!
@fraidoonhu92842 жыл бұрын
Oh wow that's how should a teacher teach!
@skl9942 Жыл бұрын
You are a master at explaining, why isnt this a frontendmasters course already? However the whole copying a slice part feels weird to me, no matter how you do it. I wonder why they didnt just let slicing a slice would create its own slice and copy the values so it get an unique address and capacity out of the box. Even adding capacity feels strange when you still point to the same address until you append to it
@ericwinchell2 жыл бұрын
24:50 wow and yikes
@secondwavesoftware3607 Жыл бұрын
Beautiful
@mohammadrezadavoodi3561 Жыл бұрын
Facinating
@Max-bf9lm5 ай бұрын
Mind=blown
@JoeEnos2 жыл бұрын
I’m following this and I can see technically why it does what it does - but the end result is nuts. Sometimes an action will modify the underlying array and sometimes it won’t… JavaScript arrays, and C# arrays and Lists just seem much less susceptible to these kinds of things. But I suppose that comes at the expense of performance and unnecessary allocation.
@oleksandrhumeniuk97247 ай бұрын
This lecture must be called "Why you should never use go". 😁
@Lakmalniranga Жыл бұрын
Another million dollar bug 😅
@sravant2 жыл бұрын
After seeing this i'm scared to use slice without capacity syntax. :)
@hamzamasood703 Жыл бұрын
Even if you use the capacity syntax, if you an element of an index in slice c that also exists in slice a, then slice a will also get changed. Regardless of the capacity. YIKES
@seandougherty30223 ай бұрын
@@hamzamasood703 well yeah, it's a reference. that's how that works :)
@joeljose66082 ай бұрын
Array is immutable by nature , But can be mutated using a slice🥲. This concept kills me.
@plutackАй бұрын
what i understand from this, someone should validate. If you are ever going to have any reason to slice an array.. you are better of creating a slice from the beginning and let go handle the underlying array.
@MrVipulLal2 ай бұрын
Sorry, but I think C or even c++ is way easier to understand and use