umka-lang icon indicating copy to clipboard operation
umka-lang copied to clipboard

Null dynamic arrays could be considered valid

Open ske2004 opened this issue 3 years ago • 0 comments

Like in go, null slices are considered valid, of length zero.

	var s []int
	fmt.Println(s, len(s), cap(s))
	for i := range s { // no error 
		fmt.Println("%d", i)
	}

When writing UI code, I often rely on zero initialization, and if I forget to initialize the empty slices, I get an error if I try to insert something or iterate it. It would be nice to have the slices initialize automatically out of convenience's sake. I'm open for discussing this

ske2004 avatar Jul 27 '22 08:07 ske2004