I don't know Lift, but this is a general question. First of all, the ::
is a Scala cons operator:
scala> 1 :: 2 :: List(3, 4)
res0: List[Int] = List(1, 2, 3, 4)
This means that super.validations
is some sort of a sequence and valMinLen(3, "Link URL must be at least 5 characters") _
is a single value in that list.
From the context it looks obvious that in overridden validations
method they are calling super
version and prepend some extra validation at the beginning.
This extra validation is created by a call to valMinLen()
. However this extra call does not return an element matching the type of validations
list - but a function. Instead of prepending the function value we are explicitly saying (by adding _
suffix`) that we want to prepend a function itself, not a return value of that function.
Code snippet is worth a thousand words:
scala> def f = 3
f: Int
scala> def g = 4
g: Int
scala> val listOfInts = List(f, g)
listOfInts: List[Int] = List(3, 4)
scala> val listOfFunctions = List(f _, g _)
listOfFunctions: List[() => Int] = List(<function0>, <function0>)
Compare the type of listOfInts
and listOfFunctions
. I believe the f _
syntax is called partially applied function in Scala world.
minimumValidation
before you have declared it? – Christopherchristopherso