gpt4 book ai didi

lua - Lua中 ' and "的区别

转载 作者:行者123 更新时间:2023-12-03 11:18:32 24 4
gpt4 key购买 nike

我只是有一个一般性的问题。

在 Lua 中使用单引号和双引号有什么区别吗?

例子:

require('test.lua')
require("test.lua")

当我用 PAWN 编程时,一种类似于 C 的语言,单引号可以用于字符,但不能用于文本字符串,你必须对它们使用双引号。

如果没有区别,建议使用哪个?

这个问题很可能已经得到回答,但是我没有找到已经回答的主题。

谢谢你。

最佳答案

不。没有区别,除了您可以将另一个包含在您正在使用的内部。

-- No difference between these
myStr = "Hi!!"
myStr = 'Hi!!'
myStr = [[Hi!!]] -- The 'weird' way to make a string literal IMO...

-- Double quotes enclosed in single quotes
myStr = 'My friend said: "Hi!!"'

-- Single quotes enclosed in double quotes
myStr = "My friend said: 'Hi!!'"

-- Single and double quotes enclosed in double brackets
myStr = [[My friend said: "What's up?"]]

见: Strings in Lua想要查询更多的信息。

关于lua - Lua中 ' and "的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17202195/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com