How do I use String interpolation in a Groovy multiline string?

Instead of using ''' for the GString or multi-line string use """

def cretanFood     = "Dakos"  
def mexicanFood    = "Tacos"
def bestRestaurant = """${mexicanFood} & ${cretanFood}"""
print bestRestaurant​

GString enclosed in ''' will not be able to resolve the placeholder - $. You can find more details in the Groovy Documentation under the heading String and String Summary Table block.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)