12

Null-Safe Navigation Operator

 1 year ago
source link: https://blogs.sap.com/2023/07/01/null-safe-navigation-operator/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
July 1, 2023 Less than a 1 minute read

Null-Safe Navigation Operator

Dear community, have you ever heard of the “Null-Safe Navigation Operator”? Me not which isn’t bad either. I can’t know everything, especially when it’s fairly new. I came across the term on this blog together with an example like that:

" old syntax 
IF lv_object IS NOT INITIAL.

" new syntax
IF lv_object?.

That caught my attention (not because of the Hungarian notation). I know the “Safe Navigation Operator” which is available in various programming languages to avoid the “Pyramid of doom“. So some kind of syntactic sugar.

I was interested in the example because I wouldn’t use IS NOT INITIAL on a reference variable. In this case IS BOUND would be my choice. Also, I wouldn’t expect ABAP language designers to put a “?.” combination at the end of an statement. That looks a bit strange.

After some research: I couldn’t find anything about this in the official latest ABAP keyword documentation (ABAP for Cloud Development). Also, I could not develop a syntactically error-free example on the SAP BTP ABAP Trial Environment.

Either there is an innovation for ABAP coming in the near/far future or the information is … simply wrong. Who knows the truth? 🙂

Oh, there is another “interesting” example on the mentioned blog that doesn’t work for me:

" old syntax
IF lv_condition = 'X'.

" new syntax
IF lv_condition = 'X' ? 'Yes' : 'No'.

Many thanks for reading and stay healthy

Michael


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK