WinWrap® Basic scripts now supports "Nothing propagation". The ?., ?( and ?! operators allow the expression to the left of the operator to be Nothing. When that is the case, the result is Nothing. The type of the result depends on the final type (T) returned by the final method/property. If T is a reference type (like StringBuilder) then the expression's result type is the same. However, when T is a value type (like Double) then the expression's result type is IsNullable<T>.
'#Language "WWB.NET" Class Location Public Latitude As Double Public Longitude As Double End Class Class City Public Location As Location End Class Sub Main Dim c As City = Nothing Dim Latitude As Double? = Nothing ' Access a value Using the Nothing Propagation Operator ?. Latitude = c?.Location.Latitude ' Nothing ' Access a value Using the DOT Operator . If c IsNot Nothing AndAlso c.Location IsNot Nothing Then Latitude = c.Location.Latitude End If Debug.Print Latitude End Sub
The example above shows how using the Nothing Propagation operator ?. greatly simplifies property value access where the object may be Nothing.
Copyright Polar Engineering, Inc.