无法弄清楚如何在多行上声明字符串数组 [英] Can't figure out how to declare a string array on multiple lines

查看:92
本文介绍了无法弄清楚如何在多行上声明字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码在运行时 导致错误,但编译.

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)

这篇关于无法弄清楚如何在多行上声明字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆