string concatenation in Groovy seems unconvenient

Posted by Zombies on Stack Overflow See other posts from Stack Overflow or by Zombies
Published on 2010-04-26T16:13:40Z Indexed on 2010/04/26 16:43 UTC
Read the original article Hit count: 110

Filed under:

My goal is to write this:

println "this should be 3: ($1+2)" //this is invalid groovy, it won't run

Yet this is valid in ruby. Is there a way I can put statements that will eval inside a string or must I use complete variables names? I am basically looking for the Ruby equivalent of:

puts "this shoud be 3: #{1+2}" #this is valid ruby

© Stack Overflow or respective owner

Related posts about groovy