x10-struct-example.x10 298 B

12345678910111213141516
  1. struct Complex {
  2. val real:Double;
  3. val img :Double;
  4. def this(r:Double, i:Double) {
  5. real = r; img = i;
  6. }
  7. def operator + (that:Complex) {
  8. return
  9. Complex(real + that.real,
  10. img + that.img);
  11. }
  12. }
  13. val x = new Array[Complex](1..10);