eclipse-archived / ceylon.tool.converter.java2ceylon

Java to Ceylon converter
Apache License 2.0
10 stars 7 forks source link

Array initialization is lost #4

Open bjansen opened 9 years ago

bjansen commented 9 years ago

The following Java code

return new String[] { "0", "1", "2" };

results in

return ObjectArray<String>();
rohitmohan96 commented 9 years ago

But you can't do something like that in Ceylon right?

luolong commented 9 years ago

Well, you can write more Ceylonic way instead:

return ["0", "1", "2"];
bjansen commented 9 years ago

I guess this could work:

return createJavaStringArray({"0", "1", "2"})

@luolong we are trying to keep the original Java types, because the converted code might be used with interop. I think we could add an option to the converter to convert things like Java arrays to Ceylon sequences?

luolong commented 9 years ago

I think it would be a good idea ...

Sometimes you want to use it for interop, but I would also not mind using it to just for porting code from Java to Ceylon...

rohitmohan96 commented 8 years ago

With ff98c4b, it converts:

new String[] { "0", "1", "2" };

to

createJavaObjectArray<String>({"0", "1", "2"});

but converts

String[]  s = {"1", "2"};

to

ObjectArray<String> str2 = {"1", "2"};