digitalmars.D.learn - primitive type variables not nullable ?
- Venkat Akkineni (25/25) Feb 08 2015 colors = [
- Venkat Akkineni (2/2) Feb 08 2015 Never mind, stupid question I realize, would delete it if I could.
- Tobias Pankrath (2/5) Feb 08 2015 Check for null with (x is null) not via printing to stdout.
- bearophile (5/6) Feb 08 2015 In most cases instead of checking dynamic arrays for null, it's
- Venkat Akkineni (2/8) Feb 10 2015
colors = [ "black" : "నలుపు", "white" : "తెలుపు", "red" : "యెరుపు", "green" : "పచ్చ", "blue" : "నీలం" ]; writefln("Before: "); writeln(colors); colors = null; writefln("after: "); writeln(colors); This above bit of code is trying to delete all elements at once by assigning a null to colors associative array. Interesting thing is the write output after assigning null to colors variable shows "[]". Here is the output. Before: ["blue":"నీలం", "red":"యెరుపు", "white":"తెలుపు", "green":"పచ్చ", "black":"నలుపు"] after: [] So primitive types can never be null ? An null assignment would set the primitive type variable to a default value ?
Feb 08 2015
Never mind, stupid question I realize, would delete it if I could. http://stackoverflow.com/questions/11047276/null-for-primitive-data-types
Feb 08 2015
On Sunday, 8 February 2015 at 23:13:33 UTC, Venkat Akkineni wrote:Never mind, stupid question I realize, would delete it if I could. http://stackoverflow.com/questions/11047276/null-for-primitive-data-typesCheck for null with (x is null) not via printing to stdout.
Feb 08 2015
Tobias Pankrath:Check for null with (x is null) not via printing to stdout.In most cases instead of checking dynamic arrays for null, it's better to use std.array.empty. Bye, bearophile
Feb 08 2015
Thanks Gentlemen. That helped. On Monday, 9 February 2015 at 00:00:00 UTC, bearophile wrote:Tobias Pankrath:Check for null with (x is null) not via printing to stdout.In most cases instead of checking dynamic arrays for null, it's better to use std.array.empty. Bye, bearophile
Feb 10 2015