Type parameterization in Scala
- by horatius83
So I'm learning Scala at the moment, and I'm trying to create an abstract vector class with a vector-space of 3 (x,y,z coordinates). I'm trying to add two of these vectors together with the following code:
package math
class Vector3[T](ax:T,ay:T,az:T) {
def x = ax
def y = ay
def z = az
override def toString = "<"+x+", "+y+",…