Re:C#: No, you don’t get to use the “as” operator any more
by munificent on Friday April 29, 2011 @06:18PM
(#2499214)
If you have to check it for null then, by definition, some_field here isn't a nullable type. If it was, you'd just do:
Am I missing something here?
[ Parent
| on HN ]
Re:C#: No, you don’t get to use the “as” operator any more
by masklinn on Saturday April 30, 2011 @03:44AM
(#2500122)
C# (values) or Nice don't use a full, explicit nullable generic type, and instead tag the original type (`int?` for C#, `?String` for Nice).
This means some_field could be a type tagged as nullable (e.g. `some_field` would be defined as ?Foo).
An alternative would be `@NotNull` opt-in anotations, where `some_field` would not be tagged, therefore nullable, therefore could hold the value `null`.
Thus, if you have to check it for null then `some_field` is a nullable reference, in a language which may have nullable and non-nullable references.