Sawyer
Sawyer

Reputation: 15917

Question mark operator usage in Lift

Lift framework provides an Easy way to define a Sitemap.

I don't quite understand the example it provides. what does ? and / mean in the following snippet?

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

Upvotes: 1

Views: 879

Answers (2)

Sawyer
Sawyer

Reputation: 15917

Both ? and / here are methods.

/**
   * 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)

Menu constructor returns a PreMenu type, the / method defined in 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

Upvotes: 1

pedrofurla
pedrofurla

Reputation: 12783

I know nothing about Lift, but by looking at the ScalaDoc for S it's clear that S ? str returns a localization property (check this for more on localization) or in case of not finding the property the string it self.

Upvotes: 0

Related Questions