Cans inside Cans says Use a for comprehension to me:
for (r - S.request; loc - r.location; link - loc.createDefaultLink) yield
link.text
It's a few more characters, but IMHO, more readable.
On Wed, Oct 15, 2008 at 7:14 PM, Charles F. Munat [EMAIL PROTECTED] wrote:
Yes, this does help a
Please also see:
http://blog.lostlake.org/index.php?/archives/50-The-Scala-Option-class-and-how-lift-uses-it.html
Can[T] is just like Option[T]
Marius wrote:
to get stuff out of a can you can do:
1. Pattern matching
having c a Can[String]
c match {
case Full(value) = //do something
Thanks. I have read everything I could find on this but I think I'm just
a bit dense about it. Probably, it's just unfamiliarity with the syntax
of Scala as a whole and functional programming in general (or maybe I'm
just stupid). Hopefully, at some point the light bulb will come on and
this
Charles,
A Can is a container... it can contain a thing or be empty.
You can transform the contents of a Can from one thing to another using
map(). map() on Can, Option, List is exactly the same as map() on Array
in Ruby:
irb(main):004:0 [1,2,3].map{|v| v.to_s + Cats}
= [1 Cats, 2 Cats, 3
Also check out CanSpec.scala to get an idea of how Cans can be used.
--j
On Wed, Oct 15, 2008 at 9:33 AM, David Pollak [EMAIL PROTECTED] wrote:
Charles,
A Can is a container... it can contain a thing or be empty.
You can transform the contents of a Can from one thing to another using
Charles, to put this in the context of the JPA stuff I'm working on, here's
the pattern I would use for, say, viewing an Author when I have a
corresponding RequestVar:
object passedAuthor extends RequestVar[Can[Author]](Empty)
def view (xhtml : NodeSeq) : NodeSeq = passedAuthor.map({ author =
Ah, that's a good idea. Didn't think of that.
Chas.
Jorge Ortiz wrote:
Also check out CanSpec.scala to get an idea of how Cans can be used.
--j
On Wed, Oct 15, 2008 at 9:33 AM, David Pollak [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] wrote:
Charles,
A Can is a container...
Yes, this does help a bit.
I actually understand the Can (and Option) very well, and I think it's a
great idea (though the added advantage of the Can doesn't seem to be
heavily used yet).
The problem I was having was dealing with cans inside cans inside cans.
But after reading everything