Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vect2 (val x: Float, val y: Float) {}
- def add(other: Vect2*):Vect2 = {
- var xTot = 0f; var yTot = 0f
- other.foreach(pt => {xTot += pt.x; yTot += pt.y})
- new Vect2(xTot, yTot)
- }
- add(new Vect2(3,4), new Vect2(3,4), new Vect2(3,4))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement