[英]Cast wrapper class to primitive in Xtend
I have a for loop, in which I put Double
values inside an array. 我有一个for循环,在其中将
Double
值放入数组中。 Normally the values are from type double
but as Xtend doesn't explicitly specify data types (and does this automatically) they are treaded as Double
s. 通常,这些值来自
double
类型,但是由于Xtend并未明确指定数据类型(并且会自动执行此操作),因此它们会作为Double
。
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[]
? 如何将
Double
为double
或Double[]
为double[]
?
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. 投射虽然也可以。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.