Opened 11 years ago
Closed 11 years ago
#2505 closed Feature Request (Duplicate)
Array create without declaration
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | Severity: | None | |
Keywords: | Cc: |
Description
Local $aData = ['p','e','t'] ;OR _my(['p','e','t']) Func _my($aD) ;... EndFunc ;OR Local $aData[1][3] ;create array $aData[0] = ['p','e','t'] ;fill the first element ;must be the same as ;Local $aData[1][3] ;$aData[0][0] = 'p' ;$aData[0][1] = 'e' ;$aData[0][2] = 't'
Attachments (0)
Change History (6)
comment:2 Changed 11 years ago by BrewManNH
comment:3 Changed 11 years ago by guinness
This is the correct format.
#include <Array.au3> Local $aArray[] = [0, 1, 2, 3] _ArrayDisplay($aArray)
comment:4 Changed 11 years ago by BrewManNH
The requesters first example works as well.
Local $aData = ['p','e','t']
Creates an array with 3 elements containing p, e, and t.
comment:5 Changed 11 years ago by anonymous
But cant like this:
Func test()
Return ['t','e','s','t']
EndFunc
comment:6 Changed 11 years ago by Mat
What you are asking for are called literal arrays.
The idea has been looked at before. I'm not sure how far it got, or whether it is still on the table.
comment:7 Changed 11 years ago by Mat
- Resolution set to Duplicate
- Status changed from new to closed
Duplicate of #2548. I'm going to bend the rules slightly and close this ticket as a duplicate of the other one (don't shoot me guys) as the other ticket is better.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
You can already use the first format to declare an array in the latest beta.