On Saturday, 24 May 2014 at 18:18:37 UTC, John Colvin wrote:
if you use foreach(dchar c; s) you will get the iteration by
code-point you are looking for.
Actually I was trying to prevent decoding :) It just occurred to
me it can be tricky in generic code.
On Saturday, 24 May 2014 at 16:46:42 UTC, Kagamin wrote:
foreach over string apparently iterates over chars by default
instead of dchars. Didn't it prefer dchars?
string s="weiß";
int i;
foreach(c;s)i++;
assert(i==5);
Nope.
if you use foreach(dchar c; s) you will get the ite
On 05/24/2014 09:46 AM, Kagamin wrote:
foreach over string apparently iterates over chars by default instead of
dchars. Didn't it prefer dchars?
I don't think so. The range algorithms iterate by dchar though.
string s="weiß";
int i;
foreach(c;s)i++;
assert(i==5);
Ali
On 2014-05-24 12:46, Kagamin wrote:
foreach over string apparently iterates over chars by default instead of
dchars. Didn't it prefer dchars?
string s="weiß";
int i;
foreach(c;s)i++;
assert(i==5);
A string is defined by:
alias string = immutable(char)[];
It doesn't add a
foreach over string apparently iterates over chars by default
instead of dchars. Didn't it prefer dchars?
string s="weiß";
int i;
foreach(c;s)i++;
assert(i==5);
"Jesse Phillips" wrote in message
news:ij2drt$1mq3$1...@digitalmars.com...
>
> Magic.
>
> No really, the best I can tell is that the compiler will try to run the
> foreach loop at compile-time if there is something in the body that must
> be evaluated at compile time.
>
Actually this happens b
On 02/11/2011 05:27 AM, Jesse Phillips wrote:
spir Wrote:
But in your example the symbol a does not look like a constant, instead it the
loop variable. Do, how does it work?
Magic.
No really, the best I can tell is that the compiler will try to run the foreach
loop at compile-time if there
spir Wrote:
> But in your example the symbol a does not look like a constant, instead it
> the
> loop variable. Do, how does it work?
Magic.
No really, the best I can tell is that the compiler will try to run the foreach
loop at compile-time if there is something in the body that must be eva
On 02/11/2011 01:02 AM, Ali Çehreli wrote:
I don't have answers to your other questions.
On 02/10/2011 03:25 PM, spir wrote:
unittest {
auto i = 1;
auto s = "i";
It works if you define s as:
enum s = "i";
writeln(mixin("i")); // compiler happy up to here --> "1"
writeln(mixin(s)); //
I don't have answers to your other questions.
On 02/10/2011 03:25 PM, spir wrote:
> unittest {
> auto i = 1;
> auto s = "i";
It works if you define s as:
enum s = "i";
> writeln(mixin("i")); // compiler happy up to here --> "1"
> writeln(mixin(s)); // compiler unhappy --> "Error: argument
On 02/10/2011 11:32 PM, Jesse Phillips wrote:
enum FileName : string {
> > file1 = "file1.ext",
> > file2 = "file2.ext"
> > }
> >
> > void main(string args[])
> > {
> >foreach(a; __traits(allMembers, FileName))
> >writeln(mixin("FileName." ~ a));
> > }
>
> Why
spir Wrote:
> On 02/10/2011 08:22 PM, Jesse Phillips wrote:
> > enum FileName : string {
> > file1 = "file1.ext",
> > file2 = "file2.ext"
> > }
> >
> > void main(string args[])
> > {
> > foreach(a; __traits(allMembers, FileName))
> > writeln(mixin("FileName." ~ a));
> > }
>
> Why t
On 02/10/2011 08:22 PM, Jesse Phillips wrote:
Nrgyzer Wrote:
Hey guys,
I'm trying to iterate over an enumeration which contains strings like
the this:
enum FileName : string {
file1 = "file1.ext",
file2 = "file2.ext"
}
I already found this article: http://lists.puremagic.com/pipermail/
digit
== Auszug aus Jesse Phillips (jessekphillip...@gmail.com)'s Artikel
> Nrgyzer Wrote:
> > Hey guys,
> >
> > I'm trying to iterate over an enumeration which contains strings
like
> > the this:
> >
> > enum FileName : string {
> > file1 = "file1.ext",
> > file2 = "file2.ext"
> > }
> >
> > I already fo
Nrgyzer Wrote:
> Hey guys,
>
> I'm trying to iterate over an enumeration which contains strings like
> the this:
>
> enum FileName : string {
> file1 = "file1.ext",
> file2 = "file2.ext"
> }
>
> I already found this article: http://lists.puremagic.com/pipermail/
> digitalmars-d/2007-July/021920
Hey guys,
I'm trying to iterate over an enumeration which contains strings like
the this:
enum FileName : string {
file1 = "file1.ext",
file2 = "file2.ext"
}
I already found this article: http://lists.puremagic.com/pipermail/
digitalmars-d/2007-July/021920.html but it's an enum which contains
in
16 matches
Mail list logo