Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

error comparing array and tuples

Open adbenitez opened this issue 3 years ago • 0 comments

Python:

def compare():
    x = [1,2]
    y = [1,2]
    console.log(f"array: {x!r} == {y!r} => {x == y}")
    x2 = (1,2)
    y2 = (1,2)
    console.log(f"tuple: {x2!r} == {y2!r} => {x2 == y2}")

generated javascript:

export var compare = function () {
	var x = [1, 2];
	var y = [1, 2];
	console.log ('array: {} == {} => {}'.format (x, y, x == y));
	var x2 = tuple ([1, 2]);
	var y2 = tuple ([1, 2]);
	console.log ('tuple: {} == {} => {}'.format (x2, y2, x2 == y2));
};

Console output:

array: [1, 2] == [1, 2] => False 
tuple: (1, 2) == (1, 2) => False

It seems arrays can't be compared that way in JavaScript: https://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript

adbenitez avatar Feb 01 '22 10:02 adbenitez