list_split_2.gravity 358 B

1234567891011121314151617
  1. #unittest {
  2. name: "List split test 2";
  3. result: "the cat sat on the mat";
  4. };
  5. func main() {
  6. var testString = "the %animal% sat on the mat";
  7. var bestEffort = testString.split(" ");
  8. var result = [];
  9. for (var s in bestEffort) {
  10. if (s == "%animal%") s = "cat";
  11. result.push(s);
  12. }
  13. return result.join(" ");
  14. }