4 ms·
But how do you handle those optional values then? Let's say you run a classifieds site, some of your users will probably prefer not to specify a price, it has t
by ivanhoe 8y ago
But how do you handle those optional values then? Let's say you run a classifieds site, some of your users will probably prefer not to specify a price, it has to be an optional value. Or age field on a dating sites. How do you filter that data, or handle sorting on that field, without using null values to mark those that are undefined?
- Munksgaard 8y agoThat has been done with option types in functional languages since at least the 80s. It's not hard.
- tigershark 8y agoOption types and comprehensive pattern matching in F#. If you just need to filter them you can simply use Seq.choose.
- coldtea 8y agoe.g: sum = 0 for entry in entries: case (val): null: pass number n: sum += n endcase in pseudocode. Several languages have offered this since forever (eg. Haskell and Maybe). The fun part is that the typesystem enforces that you check all possible cases -- or only lets you explicitly un wrap potentially null values. So it's not like a C programmer checking if (x == NULL) manually.