The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

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 Enzomatrix2009-01-29 02:27:27
    Sounds good to me... by mekkanik_mike2009-01-29 03:20:08
      For example, but you forgot the constructor.. by Enzomatrix2009-01-29 04:27:32
        That's C#'s Nullable<T> class, right there. (n/t) by bwkaz2009-01-29 08:58:58
  null. by aix tom2009-01-29 02:45:34
    Comparison is easy, but use isn't. by Khaar2009-01-29 03:31:03
      Even the generic (aka template) type? by bwkaz2009-01-29 09:02:06
    How would that compare ? by SciSSorS2009-01-29 04:28:00
      Yes, I think so.. by Enzomatrix2009-01-29 04:30:31
        Oh, kind of overloaded op for exceptional NULL by SciSSorS2009-01-29 04:48:09
    null indeed by langerjan2009-01-29 07:54:51
  Maybe a by Mad Marty2009-01-29 02:48:49
  Here's how I'd do it: by JimK2009-01-29 02:48:57
    you cant have a variable/object typed void. by mekkanik_mike2009-01-29 03:21:05
      But this isn't C/++, so I can :-) (n/t) by JimK2009-01-29 04:18:15
      Actually, IIRC, in C# it's possible... by Enzomatrix2009-01-29 04:29:09
        ugh. by mekkanik_mike2009-01-29 20:27:41
  How about a pointer that's NULL when it's not set? by Apo2009-01-29 03:38:06
    <Deleted><Deleted>2009-01-29 08:58:15
      Moderated: Double Post (n/t) by Nea2009-01-29 08:58:27
    You can just hit preview and it automatically adds (n/t) by Spisefisken2009-01-29 03:49:38
      You can just hit refresh by Spisefisken2009-01-29 03:51:30
    I hated pointers when I was still in school. by Khaar2009-01-29 04:35:41
  NULL should get the job done by Bedda2009-01-29 04:10:51
  If your doing it in .NET 2.0+ then use a nullable by sazzer2009-01-29 04:54:06
  By the time is is used, it must be initialized by huitzilopochtli2009-01-29 05:11:34
  I'd use Python and tak None as the non-value (n/t) by moddermonster2009-01-29 09:21:45

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)