Re: Just a little question before 4.0 will be released
- Posted by DerekParnell (admin) Feb 18, 2009
- 1081 views
nurminski said...
Greetings.
Sorry, if I am missing something vital in documentation, but is there a way for difining stings in Euphoria in 'heredoc' style?
Ok, I can do this. I suggest this syntax ...
k=#/ here comes the text as it will be present, no need to escape " and ' and other stuff /
The idea is that if a '#' is found that is immediately followed by any one of #'`~$^/\|, it indicates the begining of a string literal that terminates with the next occurance of whatever character followed the initial '#'. The one exception here is that if the resulting text begins with a new-line character, the text is trimmed of the leading new-line and any trailing new-line character.
-- Example Code -- constant s = #/"one" "two"/ constant t = #` "three" "four" ` constant u = #$ "three" "four" $ printf(1, "[%s]\n", {s}) printf(1, "[%s]\n", {t}) printf(1, "[%s]\n", {u}) ------------------
This would output ...
["one" "two"] [ "three" "four" ] ["three" "four"]