May 03, 2020
In C++ I just use -fpermissive

foreach(i; tuple(10, "lemon", false, "John", 1.6, 'c'))
{
		writeln(i);
		if(i == "John") break; // Error
}
May 03, 2020
On 5/3/20 4:03 PM, Marcone wrote:
> In C++ I just use -fpermissive
> 
> foreach(i; tuple(10, "lemon", false, "John", 1.6, 'c'))
> {
>          writeln(i);
>          if(i == "John") break; // Error
> }

I am not sure I understand your question because it already omits an error. If you're asking how to get that code do what I think you want, then the 'is' expression can be used with 'static if' to include the comparison into the program only for string types:

import std.typecons;
import std.stdio;

void main() {
  foreach(i; tuple(10, "lemon", false, "John", 1.6, 'c')) {
    writeln(i);
    static if (is (typeof(i) == string)) {
      if(i == "John") break;
    }
  }
}

Ali