String interpolation is a programming language feature that allows inserting variables, arithmetic expressions, function calls directly into a string. String interpolation provides more easy and intuitive content-specification and string formatting as compared with string concatenation.
String interpolation in CoffeeScript : CoffeeScript provides the feature of string interpolation being inspired from Ruby language. This feature includes variables in strings and can take multi-line strings without the need of an escape character. CoffeeScript allows multiple expressions inside the interpolation.
String interpolation in CoffeeScript is done using double quotes(“”
), a hash tag(#
), and a pair of curly braces({}
). The string is to be declared inside the double quotes and the variable that is to be interpolated is placed within the curly braces that are after hashtag symbol.
Syntax :
name = "FtL"
message = " Hello from #{name} "
The above variable is interpolated only of the string is enclosed within double quotes (“”
).