Re: Testing for NULL
- Posted by ghaberek (admin) Sep 04, 2015
- 1863 views
SDPringle said...
I think there is value in having a distinct type that allow for the dummy value. Naming convention preferences aside I would call it StringOrNull but not String. I would make another type String that would NOT allow NULL.
Yeah, that's probably a better idea. C# allows for this with Nullable Types, so "string?" and "string" are two different things (nullable and non-nullable, respectively).
Too bad "?" isn't a valid type name character in Euphoria.
public type String( object x ) return string(x) end type public type StringOrNull( object x ) return string(x) or equal(x, NULL) end type
-Greg
P.S. I'm not trying to compare Euphoria to C#, just using it as an example to show that such conventions are already established in other languages.