type determination

dsmith ds at nomail.com
Mon Nov 26 21:03:52 PST 2012


How can I make something like the following work without "Error: 
cannot append type double to type string[]" ?


T[] some_function(T[] var) {
  T[] var2;
  double a = 12.34;
  string b = "hello";

  if(typeof(var).stringof == "double") {
    var2 ~= a;
  }
  if(typeof(var).stringof == "string") {
    var2 ~= b;
  }

...
}




More information about the Digitalmars-d-learn mailing list