|
Re: Xtend: How to create a local variable [message #1077133 is a reply to message #1077102] |
Thu, 01 August 2013 09:32 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
Chris,
You seem to be using template strings without any reason. Just write
ordinary Xtend with var if, else etc. directly instead of embedding it
within ''' and escaping with << and >>
def Foo(String filterPath, String filterName) {
var fullFilterName = ""
if (filterPath.length() > 0)
fullFilterName = filterPath + "." + filterName
else
fullFilterName = filterName
...
}
Hallvard
On 01.08.13 10.50, Chris Hansen wrote:
> Hello,
>
> it is a really dumb question:
>
> How do I declare re-define a local variable in Xtend?
> My try:
>
>
> def Foo(String filterPath, String filterName)
> '''
> «var fullFilterName = ""»
> «IF filterPath.length() > 0»
> «fullFilterName = filterPath + "." + filterName»
> «ELSE»
> «fullFilterName = filterName»
> «ENDIF» '''
>
> The result is that the generated Code contains the value of
> "fullFilterName", which I don't want to get printed out here.
>
> I can't figure out how I can prevent it from being printed automatically.
>
>
> Thanks,
> Chris
|
|
|
Re: Xtend: How to create a local variable [message #1077239 is a reply to message #1077133] |
Thu, 01 August 2013 12:19 |
Chris Hansen Messages: 20 Registered: July 2013 |
Junior Member |
|
|
The reason why I used Templates is:
When trying to mix Templates into the Xtend Code, the Error "This expression is not allowed in this context, since it doesn't cause any side effects." tends to occur.
Am I not allowed to use Templates within a for-Loop?
for(use : monitor.use)
{
if(use.measinstance != null)
{
'''«printAllFiltersMeasinstance(use.measinstance.type, use.measinstance.name, suffix)»''' << Causes the Error
}
}
[Updated on: Thu, 01 August 2013 12:21] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02962 seconds