Highlighted
Absent Member.
Absent Member.
780 views

Nullables

Jump to solution

When I try and set a nullable Decimal to zero I get the below error.  I did notice that if I parse the zero to a decimal it does work.

COBCH1624: cannot implicitly convert binary-char to type System.Nullable[Decimal]. 

01  testDecimal type Nullable[type Decimal] property.

method-id New

procedure division.

         set testDecimal to 0.

end method

Is this a problem with the compiler?  It seems that this code should work.

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Nullables

Jump to solution

The compiler does not currently have any specific support for nullable types, though this could certainly be a useful enhancement.  It does have support for the use of implicit and explicit conversions and System.Nullable<T> defines an implicit conversion from type T to System.Nullable<T>.  This means that you can replace the set statement in your example by:

        set testDecimal to 0 as decimal

...and the correct conversion code will be generated.

I will investigate better support for nullable types for a future compiler release.

View solution in original post

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Nullables

Jump to solution

The compiler does not currently have any specific support for nullable types, though this could certainly be a useful enhancement.  It does have support for the use of implicit and explicit conversions and System.Nullable<T> defines an implicit conversion from type T to System.Nullable<T>.  This means that you can replace the set statement in your example by:

        set testDecimal to 0 as decimal

...and the correct conversion code will be generated.

I will investigate better support for nullable types for a future compiler release.

View solution in original post

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.