You can always try

val A<: Array[Int] = new Array[Int]((0..2)*(0..3), 0);


This says, the "A is a val, and its type  must satisfy Array[Int], and 
it is initialized with new Array..."..

This permits the compiler to infer the type Array[Int](2) for A. (The 
compiler checks that this satisfies Array[Int].)

Now, you can certainly declare A as a member variable of a class without 
specifying its type, e.g.:

class F {

   val A = new Array[Int]((0..2)*(0..3), 0); // will infer type, e.g. 
Array[Int](2)

   ...

}

However, if you want to put A in a List[Array[Int]], say, then you have 
to declare

val A:Array[Int] = ....

In this case you can access A using a point, e.g.

A([1,2])

will work.

On 12/8/2010 11:55 AM, Kirak Hong wrote:
> Hi,
>
> I got an error when I run the following code :
>
> val A:Array[Int] = new Array[Int]((0..2)*(0..3), 0);
>> A(1,1) = A(1,1)+1;
>>
>> error :
>> Method or static constructor not found for given call.
>> Call: A(x10.lang.Int{self==1}, x10.lang.Int{self==1})
>>
> However, following code form programming manual seems work well.
>
> val A = new Array[Int]((0..2)*(0..3), 0);
>> A(1,1) = A(1,1)+1;
>>
> The only difference is that I specified type for A4 when define, and I need
> to do that since I want to put the A as member variable of a class.
> Can anybody please help me?
>
> Thanks,
> Kirak
> ------------------------------------------------------------------------------
> This SF Dev2Dev email is sponsored by:
>
> WikiLeaks The End of the Free Internet
> http://p.sf.net/sfu/therealnews-com
> _______________________________________________
> X10-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
>
>



------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:

WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to