1
Grails 2.4.x在这里。我浇通过一个准遗留的Grails应用程序的代码,看到这个小宝石:如果未定义XYZ,grailsApplication.config.XYZ会返回什么结果?
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
没有定义?空值?还有别的?!?
正如我记得空的地图将被返回。你可以用println来测试它 – user3718614