Skip to content

Instantly share code, notes, and snippets.

@erynofwales
Created October 24, 2015 16:40
Show Gist options
  • Save erynofwales/61768899502b7ac83c6e to your computer and use it in GitHub Desktop.
Save erynofwales/61768899502b7ac83c6e to your computer and use it in GitHub Desktop.
Error on line 23, pointing to the size() call: Cannot convert type 'Int' to expected argument type 'Int'
protocol Matrix {
typealias ElementType
static func dimensions() -> (rows: Int, cols: Int)
static func size() -> Int
init()
subscript(row: Int, col: Int) -> ElementType { get set }
}
struct Matrix4<T: FloatingPointType> : Matrix {
static func dimensions() -> (rows: Int, cols: Int) {
return (4, 4)
}
static func size() -> Int {
let dimensions = Matrix4.dimensions()
return dimensions.rows * dimensions.cols
}
private var data: [T] = [T](count: Matrix4.size(), repeatedValue: T(0))
init() {
data = [T](count: Matrix4.size(), repeatedValue: T(0))
}
subscript(row: Int, col: Int) -> T {
get {
}
set(value) {
}
}
}
@lattner
Copy link

lattner commented Jan 20, 2016

That was supposed to be Matrix4 < T > .size()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment