digitalmars.D.learn - Not getting expected behavior from compile-time conditional
- pineapple (28/28) Jan 26 2016 Here's a simple programming showing where I'm tripping up -
- =?UTF-8?Q?Ali_=c3=87ehreli?= (4/10) Jan 26 2016 Remove the extra is: :)
- pineapple (2/3) Jan 26 2016 Huh, I swear I tried that. Thanks!
Here's a simple programming showing where I'm tripping up -
void test(T)(in T value){
import std.traits;
static if(is(T == char)){
writeln("char");
}else static if(is(isNumeric!(T))){
writeln("number");
}
writeln("hi");
}
public void main(){
test('g');
test(2);
test(2.0);
}
Output is this -
char
hi
hi
hi
I was expecting output to look like this -
char
hi
number
hi
number
hi
How can I fix this?
Jan 26 2016
On 01/26/2016 04:12 PM, pineapple wrote:
Here's a simple programming showing where I'm tripping up -
void test(T)(in T value){
import std.traits;
static if(is(T == char)){
writeln("char");
}else static if(is(isNumeric!(T))){
Remove the extra is: :)
}else static if(isNumeric!(T)){
Ali
Jan 26 2016
On Wednesday, 27 January 2016 at 00:17:18 UTC, Ali Çehreli wrote:Remove the extra is: :)Huh, I swear I tried that. Thanks!
Jan 26 2016








pineapple <meapineapple gmail.com>