Open jponge opened 11 years ago
Oups, Sorry for the duplication. I copyNpaste Let's interpole embeded expressions within a String. Here's a sample test
//Given
let answer = 42
let what = "answer"
//When
let sentence = "The ${what: toUpperCase()} is ${answer}"
//Then
require(sentence == "The ANSWER is 42")
I think the variable interpolation is not that hard (IMHO) where an expresion could be tricky. Maybe we have to split this Specification in 2 (variable & expression)
Regarding the syntax, I dunno care. $
is the historical variable prefix (shell) but any symbol suit fine (Eg. #
).
The brackets could be optionnal for variable but mandatory for expressions.
I'm interested to work on this issue but I have no clue how ? I think I need to understand the JJT https://github.com/golo-lang/golo-lang/blob/master/src/main/jjtree/Golo.jjt ?
Yep
nice feature found in modern languages
And also in PHP : https://java.net/downloads/javacc/contrib/grammars/php.jj :wink:
String interpolation is a nice feature found in modern languages, such as the following in Ruby: