2016-03-04 47 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。