0

I have a for loop, in which I put Double values inside an array. Normally the values are from type double but as Xtend doesn't explicitly specify data types (and does this automatically) they are treaded as Doubles.

I tried the following:

for (i : 0 ..< list.size) {
    array.set(i, list.get(i).myvalue as double);
}

But that doesn't seem to work, although no error occurs.

How can I cast Double to double or Double[] to double[]?

John
  • 795
  • 3
  • 15
  • 38

1 Answers1

1

You don't need to cast at all. The following compiles fine:

val double[] array = #[1d,2d]
val List<Double> list = #[1d,2d]
for (i : 0 ..< list.size) {
   array.set(i, list.get(i));
}

Casting though also works.

Sven Efftinge
  • 3,065
  • 17
  • 17