[Issue 6361] To avoid a newline in multi-line strings
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 23 09:12:55 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6361
--- Comment #1 from bearophile_hugs at eml.cc 2011-07-23 09:12:53 PDT ---
Code by Andrej Mitrovic:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=141106
It shows better why this very small change in D language is not handy to do
with a library solution:
import std.algorithm;
import std.stdio;
import std.string;
string stripNewlines(string text)
{
auto x = text.countUntil("\n");
auto y = text.lastIndexOf("\n");
return text[x+1..y];
}
template EOS(string text)
{
enum EOS = stripNewlines(text);
}
void main()
{
writeln(EOS!"
- First item: 150
- Second item: 200
- Third item: 105
");
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list