October 28, 2006 error message? | ||||
|---|---|---|---|---|
| ||||
First of all, this code:
import std.stdio;
template check( char ch1, char ch2)
{
const bool check = ch1 == ch2;
}
void main()
{
const char[] s = "123+456" ;
writefln( check!( '+', s[3] ));
}
gives the following message: "s is used as a type"
Can somebody explain to me what's wrong with the code?
But if I add two characters (check the differences :-) ):
import std.stdio;
template check( char ch1, char ch2)
{
const bool check = ch1 == ch2;
}
void main()
{
const char[] s = "123+456" ;
writefln( check!( '+', (s)[3] )); // added parentheses
}
it compiles fine?
roel
| ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply