2010-12-07 74 views
1

電梯框架提供了Easy way來定義站點地圖。電梯中的問號操作員使用情況

我不太明白它提供的例子。 ?/在以下代碼段中的含義是什麼?

def siteMap() = SiteMap(Menu(S ? "Home")/"index") 
+0

你可能需要編輯你的問題,以表明這是一個提升的問題定義的/方法 - Scala沒有運營商本身,和?只是一個方法調用,所以它意味着完全依賴於上下文 - 在這種情況下,是Lift的SiteMap。 – Submonoid 2010-12-07 09:45:03

回答

1

Both?和/這裏是方法。

/** 
    * Get a localized string or return the original string. 
    * 
    * @param str the string to localize 
    * 
    * @return the localized version of the string 
    * 
    * @see # resourceBundles 
    */ 
    def ?(str: String): String = ?!(str, resourceBundles) 

菜單構造函數返回一個PreMenu型,在PreMenu

/** 
* The method to add a path element to the URL representing this menu item 
*/ 
def /(pathElement: String): Menuable with WithSlash = 
    new Menuable(name, linkText, pathElement :: Nil, false, Nil, Nil) with WithSlash 
0

我一無所知電梯,但通過看ScalaDoc for S很顯然,S ? str返回本地化屬性(檢查this更多本地化),或在沒有找到屬性的字符串時,它自身的情況。