Can't figure out how to declare a string array on multiple lines

两盒软妹~` 提交于 2020-01-05 07:49:53

问题


This code was causing errors at runtime but would compile.

Local $acceptable[] = ["Chrome",_
                        "Firefox",_
                        "IE"]

It works if I move it all on one line. However, I want to declare many elements. How do I correctly declare it over multiple lines?


回答1:


As per Language Reference - Comments (emphasis added):

Although only one statement per line is allowed, a long statement can span multiple lines if an underscore "_" preceded by a blank is placed at the end of a "broken" line. String definition cannot be split in several lines, concatenation need to be used.

Example (space before each underscore):

#include <Array.au3>

Global Const $g_aAcceptable[] = ["Chrome", _
                                 "Firefox", _
                                 "IE"]

_ArrayDisplay($g_aAcceptable)


来源:https://stackoverflow.com/questions/27228798/cant-figure-out-how-to-declare-a-string-array-on-multiple-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!