Operations (Strings)


String Operations: Concatenate


+Concatenate"hello" + " " + "world"


result_field_name: field_name + const + spec_field_name.eval


  • field_name represents a previously declared constant field of type string.
  • const represents a string or number constant such as "hello" or 1.
  • Reference spec_field_name.eval returns a result of type string or number.
  • Order matters when referencing fields. A string operation must come after all the specifications it references.


String operations require a working knowledge of references. For more on how references work see the References Section.

  • When using value references (eval) you can concatenate strings and numbers. However, this is not allowed in CUE references.


String Concatenation Specs and Constants

salutation_word: #SpecProbability & { // spec values: ["Hello", "Goodbye"] probabilities: [50, 50] } name: #SpecFakeType & { // spec fakename: "name" } expression: "!" // const salutation: salutation_word.eval + " " + name.eval + expression

CSV Example

HelloMoe Gader!Hello Moe Gader!
HelloArla Brown!Hello Arla Brown!
GoodbyeJaylen Wisoky!Goodbye Jaylen Wisoky!
GoodbyeMay Basan!Goodbye May Basan!

JSON Example Output

[ { salutation_word: "Hello", name: "Moe Gader", expression: "!", salutation: "Hello Moe Gader!", }, { salutation_word: "Hello", name: "Arla Brown", expression: "!", salutation: "Hello Arla Brown!", }, { salutation_word: "Goodbye", name: "Jaylen Wisoky", expression: "!", salutation: "Goodbye Jaylen Wisoky!", }, { salutation_word: "Goodbye", name: "May Basan", expression: "!", salutation: "Goodbye May Basan!", }, ]