我有一个配置脚本,用户可以在其中输入绝对值或百分比值的值。
绝对值写为 0.0 到 1.0 之间的值,而百分比值写为 0 到 100。
如何区分 1 和 1.0?如果我要使用字符串,那么这肯定不是问题......我想保持这个配置简单并且不必依赖字符串。
这可能吗?
回顾:
a = 1
b = 1.0
如何判断它a
与b
.
编辑 配置文件看起来像这样:
local config = {}
-- A lot of comments describing how to configure
config.paramA = 1
config.paramB = 1.0
return config
在我的处理脚本中,我读取了这样的配置:
config = require 'MyConfigFile'
config.paramA
config.paramB