开发者

What does #> operator mean in Scala Lift?

Studying Lif开发者_开发技巧t I've immediately found a non-familiar #> operator. What exactly does it mean? Example:

/**
* Put the messages in the li elements and clear
* any elements that have the clearable class.
*/
def render = "li *" #> msgs & ClearClearable

I can read the comment to know what's the line for, but am not sure about the code mechanics here.


The operator #> is used to create CSS Selector Transformers.

You provide a CSS selector as a string and then apply it to the given argument which can be a sequence, a string or a NodeSeq and get a function of type NodeSeq => NodeSeq that applies the transformations. The & is used to chain those transformations.


There is no operator in Scala, and hence, there is no #> operator.

What looks like an operator is a method, and if it is a method, it isn't in Scala but in a class. On Smalltalk, you would say, that you can send the object a #> - message.

Since the object on the right is a String, and String does not have a #>-message, there must be an implicit in scope, which takes a String, and transforms it into an object, which has such a method.

Implicits are only searched for in the code itself or directly imported code, not in code imported from imported code, so it shouldn't be too much work, to search for #>. Maybe your IDE can tell you, where it is defined.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜