equality operator for lists

mhisted's Avatar


14 May, 2021 01:39 PM

Hi Chris,

In MWorks, how does the equality operator work for lists, does it do deep comparison?
For example, are all of the following reports correct below?



var ab = [1,2,3]
if (ab == [1,2,3] {
 report('hopefully true')

var ab = ['a', 'b', 'c']
if (ab == ['a','b','c'] {
 report('hopefully true')

if (ab == [1,2,3] {
 report('hopefully false')
if (ab == 'astring' {
 report('hopefully false')

  1. Support Staff 1 Posted by Christopher Sta... on 14 May, 2021 01:47 PM

    Christopher Stawarz's Avatar

    Hi Mark,

    Yes, equality comparison is always deep, for both lists and dictionaries. All of your examples work as you expect.


  2. Christopher Stawarz closed this discussion on 25 May, 2021 04:15 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac