Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
byte33067yGo has arrays.
Slices are like arrays as well, they are just dynamically sized. Slices are just extended arrays -
@Zennoe do you mean if internally it is just a pointer, a current size and a capacity (c++ vector)? I guess slices don't have the capacity. Usually they are readonly in respect to pushing more items.
-
byte33067y@Zennoe kind of same from wht I've read ( I don't have much experience there )
@anicka-burova slices have a capacity as well as length.
Slices are like references to arrays -
manox141927ylearning go wait till interface skull fucks your brain ...
this implement that implement those so you could....
anyway when you wrap your head round its the best language ever -
@byte array slices is a subset extract from an array. Slices intention is a view in to the array. Capacity has no meaning here.
-
byte33067y@anicka-burova slices can be an independent entity
They are Go's way of implementing dynamic arrays
sl := make( [ ] int, 0, 5)
Makes a slice of length 0 and capacity 5
s := make( [ ] int, 5)
Makes a slice of length 5 and capacity 5 -
@byte I admit I never done Go. Slice is a technical term in programming, which looks like might be used wrong in Go.
In c++ vector is an implementation for dynamic sized array. Calling it vector might be a bad idea as well.
In pseudo programming, if somebody would use SLICE word, I would understand it as a view in to a subset of an array. There you wouldn't need a capacity obviously.
Sorry for misunderstanding. -
byte33067y@anicka-burova Go slice is a little different than the traditional SLICE
Yeah, I can see why they'd be misunderstood
It takes time to get your head around these things in Go, but once you do its a great language
Related Rants
-
xorith19HTML: Hate This Meaningless Life CSS: Can't Style Shit JS: Just Shit Java: Just another vicious asshole PH...
-
ObiSwagKenobi6> Receive sudden phone call in the middle of the night > Check caller, unknown number > "Either something ba...
-
dyslxr40So I named my daughter "io" everyone calls her by the name and then we register her on our local gov't to get...
Why can't GO just have arrays. Why do I have to learn new things like slices :(
undefined
go
golang
slice