logo WinWrap®
February 17, 2016

Nothing Propagation

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>.

Use Nothing Propagation in WinWrap® Basic Scripts

  • Access a member of an object expression that might be Nothing (?. operator)
  • Access an array element of an array expression that might be Nothing (?( operator)
  • Access a dictionary item of a dictionary expression that might be Nothing (?! operator)
  • Leverage built-in documentation with the autocompletion for the new operators.

Nothing Propagation is easier and more intuitive, replacing conditional code.

'#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.

See all news articles.

Copyright Polar Engineering, Inc.