The string output may be one or two lines and I would like to process it in a DSL rule with the following expression
val String str=(EliaStr.state.toString.split('\n') )
but it complains Type mismatch: cannot convert from String[] to String.
It seems to me that it may be related to the fact that arrays are not available in Xtend.
In some old posts I saw suggestions to use .get(i) but
val String str=(EliaStr.state.toString.get(0).split('\n') )
but it gives as error the method get(int) is undefined for type String (But wasn’t it previously defined type String[]?)
Is there a way in rule DSL or should I use a Javascript transform?
Thank you for your attention
Did you try it in a different sequence ?
.toString should return a string and I think thus does not know anything about get.
.split() should return an array of strings and thus should be aware of get().
I did not try it and I am not an expert with this stuff.
So shouldn’t it be similar to:
val String str=(EliaStr.state.toString.split('\n').get(0) )
val parts=EliaStr.state.toString.split('\n')
logInfo("test", "There are " + parts.size + " parts")
logInfo("test", "The first part: " + parts.get(0))
logInfo("test", "The last part: " + parts.get(parts.size-1))