When I said "I just made the variable behave as a string" I meant the value that the var contains. I was not specific enough. But yeah we are talking about the same thing.
lexikos wrote: ↑26 Sep 2022, 19:30
Apparently your variable contained a number, not a string.
Yeah and as I have no control of how that data is coming (comes from an API Call) I didnt see any problems with passing it directly to my map.
But as it turns out I do need to do some conversion prior to passing it to my map object.
lexikos wrote: ↑26 Sep 2022, 19:30
Thing is that if I pass it as a variable AHK thinks im trying to access an array index which is incorrect.
Maps are type-sensitive. Apparently your variable contained a number, not a string. You didn't force it to behave as a map key. You converted the numeric key to a string key, so instead of corresponding to nothing, it corresponds to the value previously associated with that string.
Yes, this is exactly what happened.
I think the process of converting a numeric value, passed as a variable to a map, to a string is a bit counterintuitive.
this
invoices := invoices["list"][id ""] feels really odd to me. Having no
built-in way to convert one type to another in the form of
id.toString() for example, is a bit weird. I usually dont like the
.toString stuff but is a very common way other languages solve the type conversion issues.
As soon as V2 introduced some form of types, we might need a built in way to cast/convert between them without having to resort to some hacky solutions that for me make sense at the moment, but 4 months from now im gonna see those wierd quotes and probably wont remember why I put them there in the first place