Re: check variable for undefinedness

2015-12-11 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 December 2015 at 07:39:47 UTC, Suliman wrote: if(a is null) How to check if variable "is not null" ? a !is null or !(a is null)

Re: check variable for undefinedness

2015-12-11 Thread Suliman via Digitalmars-d-learn
if(a is null) How to check if variable "is not null" ?

check variable for undefinedness

2013-12-26 Thread Dfr
In Javascript there is 'undefined', i can do something like: var a; if(a === undefined) { a = [1,2,3] } How such check can be done in D ?

Re: check variable for undefinedness

2013-12-26 Thread John Colvin
On Thursday, 26 December 2013 at 09:21:39 UTC, Dfr wrote: In Javascript there is 'undefined', i can do something like: var a; if(a === undefined) { a = [1,2,3] } How such check can be done in D ? In D, all variables are initialised to the .init value for their type when declared. If a is a

Re: check variable for undefinedness

2013-12-26 Thread Dfr
Thank you for reply. Here is what i trying to achieve, i have module-wise data structure, which should exist in form of array and associative array, but i can't calculate second form on compile time: const a = [[a,1],[b, 2], ... ]; const string[string] b = a.map!(...).assocArray; This is

Re: check variable for undefinedness

2013-12-26 Thread Rikki Cattermole
On Thursday, 26 December 2013 at 11:03:17 UTC, Dfr wrote: Thank you for reply. Here is what i trying to achieve, i have module-wise data structure, which should exist in form of array and associative array, but i can't calculate second form on compile time: const a = [[a,1],[b, 2], ... ];

Re: check variable for undefinedness

2013-12-26 Thread Jakob Ovrum
On Thursday, 26 December 2013 at 11:03:17 UTC, Dfr wrote: Here is what i trying to achieve, i have module-wise data structure, which should exist in form of array and associative array, but i can't calculate second form on compile time: const a = [[a,1],[b, 2], ... ]; const string[string] b =

Re: check variable for undefinedness

2013-12-26 Thread Gary Willoughby
On Thursday, 26 December 2013 at 11:03:17 UTC, Dfr wrote: It is ok, but i don't want calculate 'b' every time 'come_func' is called, so i'd like to do something like this: int some_func() { if(b is null) { b = a.map!(...).assocArray; } } It might not be entirely appropriate