2016-03-04 52 views
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回报,如果XYZConfig.groovy没有定义?空值?还有别的?!?

+1

正如我记得空的地图将被返回。你可以用println来测试它 – user3718614

回答

1

@ user37186​​14是正确的。结果为空Map - > [:]

由于Groovy Truth,空的Map评估为false。