groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jmeter Tea <jmeter...@gmail.com>
Subject Re: Long String concatenation failed
Date Tue, 25 Sep 2018 09:54:29 GMT
Thanks for both answers, but it's not what I need exactly
Regarding Susanne Jaeckel: I want concatenate with *specific*(not all)
values and with different order and prefix for each, e.g. "My Name is"  <<
vars["first"] >> " " << vars["last"] << "and ..."


Regarding Batuhan Bayrakçı : I'm using inside JMeter and I'm not supposed
to use "${}" it in JMeter script as ${vars["id"]}
for more see info
http://jmeter.apache.org/usermanual/best-practices.html#jsr223

On Tue, Sep 25, 2018 at 11:23 AM, Susanne Jaeckel <susanne_j@gmx.de> wrote:

> Hi!
>
> If I have a hashmap and have to concatenate them the way you show, I would
> try:
>
>
> def vars = ["id": "value", "id2": "value2", "id3": "value3"]
>
> String text = ""
> vars.each { k, v ->
>         text += "<${k}>${v}</${k}>"
> }
>
> println text
>
> Regards,
> Susanne.
>
>
> Am 25.09.2018 um 09:56 schrieb Jmeter Tea:
>
>> Hello,
>> I have to concatenate a lot of variables in a script and I want to make
>> it readable, but I failed to separate lines as in java, The following code
>> doesn't compile due to:
>> |
>> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException:
>> startup failed:
>> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>>    << vars["id2"] << "<id2>"
>> Code: Stringtext ="<id>"<<vars["id1"]<<"<id><id
>> 2>"<<vars["id2"]<<"<id2>";|
>>
>> Is there a workaround or a better way concatenation a string in groovy?
>>
>> Related question:
>> https://stackoverflow.com/questions/47786399/jmeter-groovy-
>> script-concatenation-of-variables
>>
>> Thank you
>>
>
>

Mime
View raw message