On Tuesday, 17 December 2013 at 17:17:39 UTC, Andrej Mitrovic wrote:
On 12/17/13, Byron <byron.he...@gmail.com> wrote:
I don't know why we can't do this instead:

if (foo in ["alpha", "beta", "delta"] ) {

You can come pretty close with:

if (foo in A["alpha", "beta", "delta"] )

Here's the code:

http://forum.dlang.org/thread/mailman.111.1325867961.16222.digitalmar...@puremagic.com#post-mailman.111.1325867961.16222.digitalmars-d:40puremagic.com

Wow that is a lot of hoops to jump through to simulate a fairly simple operator. Probably not something anyone new to D is going to do. the in operator needs some real love. I would think you could do even more with in

if("ello" in "Hello World") { // I would think that this could return a slice

}

LinkedList!int list = makeList();
enforce(45 in list, "oh no we must have 45 in the linked list or all is lost");

!in would be nice, not sure how it could work if in returns pointers/refs/slices


Reply via email to