Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.24 KB | None | 0 0
  1. class Vect2 (val x: Float, val y: Float) {}
  2.  
  3. def add(other:  Vect2*):Vect2 = {
  4.   var xTot = 0f; var yTot = 0f
  5.   other.foreach(pt => {xTot += pt.x; yTot += pt.y})
  6.   new Vect2(xTot, yTot)
  7. }
  8.  
  9. add(new Vect2(3,4), new Vect2(3,4), new Vect2(3,4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement