We use xxx.MIN_VALUE to represent null on both client and server (.NET).
We've been doing it in .NET for several years and now with Flex integration
it works very well.  Of course everyone needs to recognize that MIN_VALUE is
being used this way and if you actually had to store MIN_VALUE then you have
a problem, but we've never had the need.

Of course this doesn't work for Boolean, so for Boolean if you need nullable
then declare as int instead and use int.MIN_VALUE for null, 0 for false,
everything else for true. 

.NET itself now has nullable types which would be more elegant but they have
performance implications and would not provide as good interoperability with
Flex.

HTH,

Sam


-------------------------------------------
We're Hiring! Seeking a passionate developer to join our team building Flex
based products. Position is in the Washington D.C. metro area. If interested
contact [EMAIL PROTECTED]
 
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of merelypixels
Sent: Tuesday, September 18, 2007 1:16 PM
To: [email protected]
Subject: [flexcoders] nulling primitive data types

Hello All,
  I've been running into a rather frustrating issue with flex: namely
that although data types are supposedly implemented as AS classes, you
cannot null variables of primitive data types e.g.

var blah:int =  null;       //blah == 0
var blah:Number = null;     //blah == 0
var blah:Boolean = null;    //blah == false

admittedly we can define -1 as null for non-Boolean types, but what if
a negative number becomes a logical value in some case?

now this wouldn't be a problem if we didn't have to communicate with a
SQL back-end, but sometimes I need to be able to pass a null value to
the db either to signify that the current value shouldn't be changed
or to specify that information is not currently known for the value.

...

Thanks for your time,
Pixels


Reply via email to