|
|
Re: How to iterate in a collection using Xtend? [message #911083 is a reply to message #911065] |
Tue, 11 September 2012 00:03 |
Cristiano Gavião Messages: 279 Registered: July 2009 |
Senior Member |
|
|
Hi Sebastian,
Thanks for the tip.
I've found an interesting example here.
And I'm trying this but can find a way to increment the counter.
val values = "h1,h2,h3&cell11,cell12,cell13&cell21,cell22,cell23".split("&")
if (!tableRows.nullOrEmpty) {
val i = 0
for(row: tableRows)
{
val rowCellValues = row.cells.map[name.toString].join(",")
assertEquals(values.get(i), rowCellValues)
i=i+1
}
}
There is a error being indicated in the "i=i+1" sentence.
can't I create local variable with xtend? how should I do that ?
thanks,
Cristiano
|
|
|
Re: How to iterate in a collection using Xtend? [message #911224 is a reply to message #911083] |
Tue, 11 September 2012 07:54 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Cristiano,
The val keyword indicated final locals where you would use 'var' for
variable.
Please refer to the docs for details.
Best regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 11.09.12 02:03, schrieb Cristiano Gaviao:
> Hi Sebastian,
>
> Thanks for the tip. I've found an interesting example
> http://www.slideshare.net/meysholdt/testdriven-development-of-xtext-dsls.
>
> And I'm trying this but can find a way to increment the counter.
> val values =
> "h1,h2,h3&cell11,cell12,cell13&cell21,cell22,cell23".split("&")
> if (!tableRows.nullOrEmpty) {
> val i = 0
> for(row: tableRows)
> {
> val rowCellValues = row.cells.map[name.toString].join(",")
> assertEquals(values.get(i), rowCellValues)
> i=i+1
> }
> }
>
> There is a error being indicated in the "i=i+1" sentence.
>
> can't I create local variable with xtend? how should I do that ?
>
> thanks,
>
> Cristiano
|
|
|
|
Powered by
FUDForum. Page generated in 0.04144 seconds