Currently there is no char literal in Xtend. Join discussion at
def static char !(String str) {
if (str.length != 1)
throw new RuntimeException("A char literal string must have length of 1! str = " + str)
return str.charAt(0)
}
Usage:
def static void test(char x) {}
def static void main(String[] args) {
val x = !'a'
println(x)
test(x)
}
It is good for me for its concise, that is you don't need to write 'a'.charAt(0) or assign 'a' to a char variable first.
Will be good if this way is ok for all and can be added to Xtend's library.