The v2 upcoming beta news is exciting , so I started to learn the new V2 syntax.
But what makes me painful is that I can no longer use objects as before {"&":"b"}, the only solution is map("&","b"). But I think I hate it, I hate a, b, c, d, I like the well-structured a: b, c: d
How to initialize an object using classic methods?
======
I'm very sorry, I sent it in the wrong place. I request the administrator to transfer this post to "Ask For Help".
[v2-132] How to initialize an object in a classic way?
[v2-132] How to initialize an object in a classic way?
Last edited by gregster on 24 Apr 2021, 10:16, edited 1 time in total.
Re: [v2-132] How to initialize an object in a classic way?
Objects can still be created literally I think, have you tried it?
Code: Select all
obj := { boo:"rah", tee:"noh" }
msgbox(obj.boo)
msgbox(obj.tee)
Re: [v2-132] How to initialize an object in a classic way?
I already did it for you. No worries. I think it is now where it is was meant to be, in the v2 help subforum... (originally, it was in 'Scripts and Functions')
Re: [v2-132] How to initialize an object in a classic way?
and how were u "using objects as before {"&":"b"}"? im not gonna bother firing v1 up, but surely not obj.& which im fairly certain wont even compile - u had to do obj["&"], ie "the Map usage", so just use a map then
ull learn to love it. if the globalists say this about owning nothing, i think ull manage an exception for a small part of ahk just fine
Re: [v2-132] How to initialize an object in a classic way?
@post In the original version where obj was divided into arr-map, {"&":1,"&":2} is still feasible.
@gregster Thanks.
@swagfag It seems that it will take me a while to get used to the new grammar.
@gregster Thanks.
@swagfag It seems that it will take me a while to get used to the new grammar.
Re: [v2-132] How to initialize an object in a classic way?
@arcticir
Also, if you need to iterate through the AHK v2 {obj} then you can use the following loop:
Also, if you need to iterate through the AHK v2 {obj} then you can use the following loop:
Code: Select all
obj := {item:"value", item2:"value2"}
For prop, val in obj.OwnProps()
msgbox(prop " = " value)
« AHK Portable Installer » | « CallTipsForAll » | « TheArkive AHK v1 Scripts » | « TheArkive AHK v2 Scrpts » | « TheArkive on GitHub »