I’m currently reading Mark Elliot’s “Lotus Notes Developer’s Toolbox” and I’ve noticed that Mark consistently uses a technique I don’t fully understand. Here’s an example:
Mark is designing a form with a Computed, Date/Time field that is named Updated. It’s value is set to:
value:= @If(@IsDocBeingEdited; @Now; Updated);
value
Why is this done (or what are the benefits of using this approach) rather than just setting the computed field’s value to:
Functionally they are the same. It is inefficient to create a temporary variable needlessly. The way you suggested is better in that sense.
For purposes of instruction, some developers may be freaked out at first by the notion of @If returning a value. They think of it more as a logical construction of executing a statement conditionally. The use of a temporary variable here emphasizes that @If returns a value, and it is that value we are treating as the “result” of the if. Thus, beginning developers accustomed to more procedural languages may find this construction less puzzling.