COMMUNITY

Inconsistency with how Maps print

So, as I’d expect:

  • Arrays use square brackets in source code, and print with square brackets.
  • Anonymous Structures use curlies in code, and print with curlies.
var a = [1, 2, 3];
trace(a); // [1,2,3]

var as = {a: 1, b: 2};
trace(as); // {a: 1, b: 2}

Why is it that Maps print with curlies instead of the expected square brackets?

var m = ["a" => 1, "b" => 2];
trace(m); // {b => 2, a => 1}  wait, what?
// Why not   [b => 2, a => 1]  ?

I find this strange as well, and actually opened an issue about it some time ago: https://github.com/HaxeFoundation/haxe/issues/8030

1 Like

Thanks, Jens. I added a comment there.