Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not sure what the convention is for using <code>_!</code> and <code>_!!</code> in Lift, but here's a bit of background.</p> <p>Any alphanumeric identifier can have _ and a list of symbols added and still be parsed as a single identifier. For example:</p> <pre><code>scala&gt; class Example_!@%*! defined class Example_$bang$at$percent$times$bang </code></pre> <p>(In fact, you can parse almost anything as an identifier if you surround it with backticks--and this is what you do if a Java class uses a Scala reserved word, for example. Or if you want spaces in your identifiers.)</p> <p>The compiler only recognizes one symbolic ending specially, however. If there is a method that looks like a getter, then getter_= will be interpreted as a setter. (Whether you actually <em>use</em> it as a setter is up to you; it will have the semantics of a setter, anyway.) So</p> <pre><code>scala&gt; class Q { def q = "Hi"; def q_=(s: String) { println(s.reverse) } } defined class Q scala&gt; val q = new Q q: Q = Q@b5c12e scala&gt; q.q res0: java.lang.String = Hi scala&gt; q.q = "Could use this to set something" gnihtemos tes ot siht esu dluoC </code></pre> <p>In addition, the compiler reverses the order of caller and callee in <em>any</em> method that ends in <code>:</code>. This is most often seen in lists: <code>newElement :: existingList</code> is actually a call to <code>existingList.::(newElement)</code>. So, for example:</p> <pre><code>scala&gt; object Caps { def to_:(s: String) = s.toUpperCase } defined module Caps scala&gt; "Example" to_: Caps res40: java.lang.String = EXAMPLE </code></pre> <p>Any other usage of <code>_</code> + symbols is convention.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload