I start reading Lift framework source code, I find that there’re so many methods are defined using a name like methodName_? , is there a convention that _? has some special meaning?
def empty_? : Boolean = {}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
?denotes that this is a predicate, a function returningBoolean. This convention goes back to Lisp, where?(Scheme),por-p(other Lisps, simulating the question mark with a “similar” letter) also denote predicates. Think of it as asking a question, “is the object empty?”Scala will only allow mixed identifier names (containing alphanumerics and punctuation) if you separate them by
_. E.g.,doesn’t work, but
does.