Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们的项目中有一些常量。一个是服务器的 URL。在测试模式下是否可以使常数不同?
就像是:
IF InTestMode() THEN CONSTANT URL = "http://test.com" ELSE CONSTANT URL = "http://prod.com" END
谢谢。
常量实际上应该是常量。
您正在搜索的是在项目级别定义的全局变量。您可以按照您想要的方式初始化变量,使用或不使用类似的常量:
CONSTANT URL_PROD = "http://prod.com" URL_TEST = "http://test.com" END gsURL is a string = InTestMode() ? URL_TEST ELSE URL_PROD