Advertisement

Author Topic: SPON_deepEquals (DO NOT SUBMIT)  (Read 2207 times)

0 Members and 1 Guest are viewing this topic.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
SPON_deepEquals (DO NOT SUBMIT)
« on: 16 Nov 2007, 17:19:03 »
SPON_deepEquals v0.2.0
- Released: 2007-11-18
- SQF function in a single file
- Includes test mission, which is little more than a series of unit-tests/examples.

Description:
  Compares any two values, including nil, null, arrays or nested arrays, for
  equality. For our purposes, nils and nulls are considered equal to each
  other, which is contrary to how this is done in ArmA (nil == nil,
  objNull == objNull, controlNull == controlNull, displayNull == displayNull).

Parameters:
  0: _a - The first value [Any type]
  1: _b - The second value [Any type]

Returns:
  True for equality, false otherwise.

Usage:
  SPON_deepEquals = compile preprocessFileLineNumbers "SPON_deepEquals";

  _same = [[1, nil, [3]], [1, nil, [3]]] call SPON_deepEquals; // Returns true
  _same = [[1, nil, [3]], [1, [nil, 3]]] call SPON_deepEquals; // Returns false

Changelog:
  0.2.0 No longer relies on the compiled function having a particular name.
          Compares any type to any type.
          Considers nils and nulls to be equivalent to themselves.
  0.1.0 First release.
« Last Edit: 18 Nov 2007, 20:04:25 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: SPON_deepEquals (DO NOT SUBMIT)
« Reply #1 on: 18 Nov 2007, 20:01:56 »
Updated to v0.2.0 (see original post for changelog).

Still not sure about making nils and nulls equal, but I think that it makes more sense when comparing data structures than when comparing single variables.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)