Hi,

I feel I must apologise for this  post ... I've only been doing scala
for a week, and lift for 3 days, but I'm stuck.
I'm coming from an experienced java background, just struggling with
some scala constructs.

I feel I understand the basics of lambda and function literals - but
I'm blown away by some of the syntax in the lift "Getting Started"
tutorial.
For example, given :

val mylist = Array(1,2,3)
mylist..foreach(v => println(v)

Here I understand where "v" comes from - its each int in the list.

In the tutorial (http://liftweb.net/docs/getting_started/
mod_master.html)
there is a function "desc" (Listing 15) :

private def desc(td: ToDo, reDraw: () => JsCmd) =
 swappable(<span>{td.desc}</span>,
         <span>{ajaxText(td.desc,
                     v => {td.desc(v).save; reDraw()})}
         </span>)

For my own brain to try and "break it down", I have :

  private def desc(td: ToDo, reDraw: () => JsCmd) = {
    val myFunctionLiteral = (xxx: String) => {td.desc(xxx).save;
println("!!!!!!!!!Desc function :" + xxx); reDraw()}

    swappable(<span>{td.desc}</span>,
      <span>{ajaxText(td.desc, myFunctionLiteral)}</span>)
  }

This is called from the "doList" method :

private def doList(reDraw: () => JsCmd)(html: NodeSeq): NodeSeq =
 toShow.
 flatMap(td =>
   bind("todo", html,
      "desc" -> desc(td, reDraw)
   ))

I understand where the "ToDo" object "td" is coming from, and how the
"reDraw" thing works, and how they are passed to the "desc" function,
but what I don't understand at all is where the val "xxx" in
"myFunctionLiteral" comes from ?
How is it passed into the function ? Is it currying ?

I'm sorry for such a vague question, I'm totally at sea here.

Thankyou for reading this, and for any help you may provide !

Ben

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to