Created attachment 1795 [details] source code The Source Code: import std.stdio; import std.algorithm.searching : find; struct Classes { string[] _classes; alias _classes this; auto opBinary( string op: "in" )( string rhs ) { return _classes.find( rhs ); } } void main() { Classes cs; cs ~= "box"; writeln( cs._classes ); auto res = "box" in cs._classes; writeln( res ); } The Goal: - Use overload operator "in" - Check string in string[] Concrette: "box" in cs._classes; Expected: Range r = "box" in cs._classes; assert( !r.empty ); Got: Compile time error: Error: incompatible types for ("box") in (cs._classes): string and string[] Full log: C:\src\dtest-op-in>dub run Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64. dtest-op-in ~master: building configuration "application"... source\app.d(25,16): Error: incompatible types for ("box") in (cs._classes): string and string[] C:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.
You need to use “in” on your struct, not the string array. “box” in cs;
Oh, sorry ! Yes!
...and it would be the opBinaryRight :)