So other language frameworks support extension methods that work even when the object is null/nil.
Xojo doesn’t seem to support this. Is this a bug? A short-coming of the language? Can this be fixed?
For example in C#
public static IEnumerable<TSource> EmptyIfNull<TSource>(this IEnumerable<TSource> source)
{
return source ?? new TSource[] {};
}
====REASON I WANT THIS====
Since XOJO doesn’t have built in Object wrappers for the primitives
Because of this I have created nullable versions of the primitives:
For example I have a class called NullableInteger, but the problem is that you constantly have to null check them
if someObject.NullableIntProperty != null && someObject.NullableIntProperty.Value > 0 then...
This could be completely avoided if extension methods could be called with a Nil input parameter like other languages.
This code be simplified to:
if someObject.NullableIntProperty.Value > 0 then...
And if Operator_Convert supported a Nil input parameter as well, then it could be as simple as
if someObject.NullableIntProperty > 0 then...