这里有Grails2.4.x。我正在浏览一个准传统Grails应用程序的代码,并看到以下小 gem :
public static boolean isFizz() {
def isEnabled = isFizz
if (isEnabled != true && isEnabled != false) {
// Config is missing, so default to true
return true
}
isEnabled
}
真?这不应该是:
public static boolean isFizz() {
def isEnabled = isFizz
if (isEnabled == null) {
// Config is missing, so default to true
return true
}
isEnabled
}
如果未在
grailsApplication.config.XYZ
中定义XYZ
,则Config.groovy
返回什么?空值?还有吗?!?
最佳答案
@ user3718614是正确的。结果是一个空的Map
-> [:]
由于Groovy Truth,空Map
的计算结果为false。
关于grails - 如果未定义XYZ,grailsApplication.config.XYZ将返回什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35793686/