Skip to content

Can't return a slice of slices ([][]bool) #346

Description

@moritz157

I wanted to pass a slice of slices of boolean values ([][]bool). I would assume that this could simply be done like this:

func GetEmptyMatrix(xSize int, ySize int) [][]bool {
	result := [][]bool{}

	for i := 0; i < xSize; i++ {
		result = append(result, []bool{})
		for j := 0; j < ySize; j++ {
			result[i] = append(result[i], false)
		}
	}

	return result
}

In Python I then simply called the function:

from out import matrix

matrix.GetEmptyMatrix(4,4)

However, this failed with the following error: panic: interface conversion: interface {} is []bool, not *[]bool

Is passing a slice of slices generally not supported or do I have to do it in a different way (like passing a slice of pointers to slices)? If this is supported, I would suggest to maybe add an example for this because as far as I can see, there is none yet. If I'm just doing it wrong, a hint in the right direction would be greatly appreciated :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions