OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: Spooner on 16 Nov 2007, 17:19:03

Title: SPON_deepEquals (DO NOT SUBMIT)
Post by: Spooner 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.
Title: Re: SPON_deepEquals (DO NOT SUBMIT)
Post by: Spooner on 18 Nov 2007, 20:01:56
Updated to v0.2.0 (see original post (http://www.ofpec.com/forum/index.php?topic=30618.0) 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.