无法弄清楚如何在多行上声明字符串数组
问题描述:
此代码在运行时 导致错误,但将编译.
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?
答
根据语言参考-注释(添加了重点):
尽管每行只允许一个语句,但是如果在下划线"
_
" 前加空白,则长语句可以跨越多行.字符串定义不能分成多行,需要使用串联.
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)