https://issues.dlang.org/show_bug.cgi?id=11252
ag0ae...@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |ag0ae...@gmail.com Resolution|INVALID |--- --- Comment #2 from ag0ae...@gmail.com --- (In reply to Jack Stouffer from comment #1) > This enhancement request makes no sense, as the "in" operator in Python and > D do two completely different things. > > To replicate the Python behavior, you can do the following: > > import std.stdio, std.range, std.algorithm.searching; > > void main() { > if (iota(1, 10).countUntil(foo(2)) > -1) { > "yes".writeln; > } > } > > But I don't see why you would want to, as this is much faster: > > void main() { > immutable int temp = foo(2); > if (temp >= 1 && temp <= 10) { > "yes".writeln; > } > } The request is not for Python's `in`. The request is for a succinct way to do what Python's `1 < foo(2) < 10` does. The suggested solution with D's `in` would of course not do a linear search. Reopening. --