valueDiff for arrays?

Richard Gaskin ambassador at fourthworld.com
Sun Aug 5 22:40:13 EDT 2018


Mark Waddingham wrote:

 > On 2018-08-05 21:22, Richard Gaskin via use-livecode wrote:
 >> Mark Waddingham wrote:
 >>
 >>> In your use-case for 'valueDiff' - do you need to tell the
 >>> difference between a key value being the empty string and
 >>> a key value not being present at all?
 >>
 >> In my own head, any name-value pair, even one in which the value
 >> is an empty string, is worth taking into account.
 >
 > In the general case it depends on what data you are modelling with an
 > array.
 >
 > If an array key-value is modelling a field which is not optional, then
 > there is no need to distinguish between an array key being there, and
 > one not being there - i.e. all field accesses can be tRecord[tKey],
 > and your key value can be empty.
 >
 > If a field's value has to be non-empty to be valid, then you can test
 > for existence of a field by doing tRecord[tKey] is not empty. So,
 > again, presence or not presence of an array key is immaterial.

Consider an array of object properties. There, a label or name property 
can be empty, and it's useful to know that.

In most of my own work, if a key is present it's meaningful, even if its 
value is empty.

If a key is not meaningful it probably isn't in an array I'm using.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list