Roman Goyenko
Roman Goyenko

Reputation: 7080

Escape dot in GString

I have a string like this

def fileName = "$prefix-$currDate.gz"

.gz is an extension of the file and not a property and I get exception that there is no such property.

Is there a way to escape it? I tried \. which didn't work.

I know I could do

def fileName = "$prefix-$currDate" + ".gz" 

but that's not too groovy.

Upvotes: 3

Views: 2563

Answers (1)

dmahapatro
dmahapatro

Reputation: 50265

"$prefix-${currDate}.gz"

should be good.

Upvotes: 9

Related Questions