| To null or not to null? |
by Khaar |
2009-01-29 02:19:43 |
What method would you use to determine whether a numeric value (any numeric type) has been specified or not? Keep in mind that *any* value is valid.
a) nullable type - most straightforward in understanding, not so much in use
b) separate boolean - simple usage, but one logical value is stored in two variables, which must then always be used, validated and sent around in a pair
c) reserved value as undefined (e.g. MaxValue or something like that) - fairly simple usage, but a chance of logic failure
d) something else
My particular problem is in C#, and I know how I'll solve it, but I'm asking for general opinions. |
|
[ Reply ] |
|
I'd think about buildign an object around it.. | by Enzomatrix | 2009-01-29 02:27:27 |
|
Sounds good to me... | by mekkanik_mike | 2009-01-29 03:20:08 |
|
For example, but you forgot the constructor.. | by Enzomatrix | 2009-01-29 04:27:32 |
|
That's C#'s Nullable<T> class, right there. (n/t) | by bwkaz | 2009-01-29 08:58:58 |
|
null. | by aix tom | 2009-01-29 02:45:34 |
|
Comparison is easy, but use isn't. | by Khaar | 2009-01-29 03:31:03 |
|
Even the generic (aka template) type? | by bwkaz | 2009-01-29 09:02:06 |
|
How would that compare ? | by SciSSorS | 2009-01-29 04:28:00 |
|
Yes, I think so.. | by Enzomatrix | 2009-01-29 04:30:31 |
|
Oh, kind of overloaded op for exceptional NULL | by SciSSorS | 2009-01-29 04:48:09 |
|
null indeed | by langerjan | 2009-01-29 07:54:51 |
|
Maybe a | by Mad Marty | 2009-01-29 02:48:49 |
|
Here's how I'd do it: | by JimK | 2009-01-29 02:48:57 |
|
you cant have a variable/object typed void. | by mekkanik_mike | 2009-01-29 03:21:05 |
|
But this isn't C/++, so I can :-) (n/t) | by JimK | 2009-01-29 04:18:15 |
|
Actually, IIRC, in C# it's possible... | by Enzomatrix | 2009-01-29 04:29:09 |
|
ugh. | by mekkanik_mike | 2009-01-29 20:27:41 |
|
How about a pointer that's NULL when it's not set? | by Apo | 2009-01-29 03:38:06 |
|
<Deleted> | <Deleted> | 2009-01-29 08:58:15 |
|
Moderated: Double Post (n/t) | by Nea | 2009-01-29 08:58:27 |
|
You can just hit preview and it automatically adds (n/t) | by Spisefisken | 2009-01-29 03:49:38 |
|
You can just hit refresh | by Spisefisken | 2009-01-29 03:51:30 |
|
I hated pointers when I was still in school. | by Khaar | 2009-01-29 04:35:41 |
|
NULL should get the job done | by Bedda | 2009-01-29 04:10:51 |
|
If your doing it in .NET 2.0+ then use a nullable | by sazzer | 2009-01-29 04:54:06 |
|
By the time is is used, it must be initialized | by huitzilopochtli | 2009-01-29 05:11:34 |
|
I'd use Python and tak None as the non-value (n/t) | by moddermonster | 2009-01-29 09:21:45 |