I'd like to make a slick initializer for a matrix that lets me define the row and column count with a default element. How can create an extension for an Array of Arrays? When I try in the way below,
extension Array where Element == Array<SubElement> {
init(rows: Int, columns: Int, emptyDefault: SubElement) {
self = []
// implementation
}
}
I'm getting the following error:
// Same-type constraint 'Element' == 'Array<Element>' is recursive
An example usage would be
self = [[UIColor]](rows: 20, columns: 30, emptyDefault: .blue)
// This would create a matrix with 20 rows, each row having an array of 30 .blue
I want to be able to do something like that.