I am trying to verify my understanding string interpolation and string templating.
Is it correct to say that the two Java code snippets are examples of templating?
public class Person {
//showing only relevant code
public String toString() {
return "Name: " + name + " salary: " + salary + " address: " + address;
}
}
public String toString() {
return String.format("name: %s salary: %d address: %s", name, salary, address);
}
and this Groovy snippet is an example of string interpolation:
public class Person {
def name
def salary
def address
//showing only relevant parts of the code
public String toString() {
return """name: ${name} salary: ${salary} address: ${address}"""
}
}
Would it be correct to say that Java and Python support templating but not interpolation, but Groovy does support interpolation.