Reputation: 482
I am following the "Exploring Lift" book and I've tried one of their example Snippets - the only difference here is that I don't use the MegaProtoUser class but instead rolled my own one. However, I get the following problem.
Here is my Snippet:
User.currentUser.map(user =>
user.projects.flatMap(project => {
bind("e", chooseTemplate("project", "entry", in),
"name" -> Text(project.name.is),
"actions" -> {
SHtml.link("/manageProjects", () => project.delete_!, Text("Delete")) ++ Text(" ") ++
SHtml.link("/editProject", () => currentAccountVar(project), Text("Edit"))
})
})) openOr Text("You are not logged in.")
And here are the compiler errors:
inferred type arguments [Seq[scala.xml.Node]{def seq: Seq[scala.xml.Node]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}] do not conform to method openOr's type parameter bounds [B >: scala.collection.mutable.Buffer[scala.xml.Node]]
type mismatch; found : scala.xml.Text required: Seq[scala.xml.Node]{def seq: Seq[scala.xml.Node]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}; def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}
If I replace openOr Text("You are not logged in.") with open_! then it works.
Why can't I use openOr in this context, what does this error mean? And what's the proper way to do it?
Upvotes: 1
Views: 571
Reputation: 42037
The error means the compiler wants a sequence but found a single element. Try
List(Text(....))
instead of just
Text(....)
Upvotes: 2