I'm using Xtend to write an Android app, and I wanted to use the elvis operator to simplify the following (which works):
val c = if (projection != null) new MatrixCursor(projection) else new MatrixCursor(#[MediaStore$MediaColumns::DISPLAY_NAME, MediaStore$MediaColumns::SIZE])
By using elvis operator, I wrote:
val c = new MatrixCursor(projection ?: #[MediaStore$MediaColumns::DISPLAY_NAME, MediaStore$MediaColumns::SIZE])
which, as far as I understand, works in the same way.
However, I got this error in Eclipse: Type mismatch: cannot convert from Object to String[]
What's wrong with it?
I'm using Xtend 2.4, the MatrixCursor
constructor signature is MatrixCursor(String[])
, and projection
is defined explicitly as String[]
.