#How to handle indexing into empty arrays in non verbose way
20 messages · Page 1 of 1 (latest)
arrays can't be empty, you can access them without checking for errors.
they can have 0 items that what I'm talking about
I think he means slices
There's no way to check without an if somewhere, whether you want to make a helper function that checks the length for you is up to you
at this point i might just implement Vec and Option 
I don't know what those are 
🦀
does vec not panic?
Vec has methods that return option and Option has method to return default at None
wait wrong code
I would advise you to try and break the habit of calling slices arrays, they're not the same thing.
I understand that using concepts from other languages seems easier but if they set root they'll be hard to get rid of
(re: deleted code)
func ReturnFirstOrDef[T any](arr []T) T {
var t T
if len(arr) == 0 {
return t
}
return arr[0]
}
here is the code
didn't even know its an issue
will remember that
👍
not calling things by their proper name is almost always an issue 
this is one example of why the distinction matters #1138410843302789210 message
it's fine to use crutches, you just need to be aware of that so that they don't bite you in the future
ya sould figure it out sooner silces don't have methods any fancy methods on them