digitalmars.D.learn - isExist in associate array
- raymond (6/6) Dec 09 2008 how to check if array key exist in array or not? for example
- Ellery Newcomer (2/10) Dec 09 2008 if("test1" in t) writefln("exists");
- Spacen Jasset (6/17) Dec 10 2008 Also useful:
- Jarrett Billingsley (7/12) Dec 10 2008 Almost; it's char[]* value, since in always returns a Value* type.
how to check if array key exist in array or not? for example char[] [char[]] t; t["tes1"]="val1"; t["tes2"]="val2"; t["tes3"]="val3"; if (t["test1"]) writefln("NONE");
Dec 09 2008
raymond wrote:how to check if array key exist in array or not? for example char[] [char[]] t; t["tes1"]="val1"; t["tes2"]="val2"; t["tes3"]="val3"; if (t["test1"]) writefln("NONE");if("test1" in t) writefln("exists");
Dec 09 2008
Ellery Newcomer wrote:raymond wrote:Also useful: char[] value; if ( (value = "test1" in t) ) { writefln(value); }how to check if array key exist in array or not? for example char[] [char[]] t; t["tes1"]="val1"; t["tes2"]="val2"; t["tes3"]="val3"; if (t["test1"]) writefln("NONE");if("test1" in t) writefln("exists");
Dec 10 2008
On Wed, Dec 10, 2008 at 12:16 PM, Spacen Jasset <spacenjasset yahoo.co.uk> wrote:Also useful: char[] value; if ( (value = "test1" in t) ) { writefln(value); }Almost; it's char[]* value, since in always returns a Value* type. (and it would then be writefln(*value)) Aaalso useful: if(auto value = "test1" in t) writefln(*value);
Dec 10 2008