I saw this in my generated GSP pages. What does the ? mean?
<g:textField name="name" value="${phoneInstance?.name}" />
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.
It’s the “Safe Navigation Operator”, which is a Groovy feature that concisely avoids null pointer exceptions. See http://docs.groovy-lang.org/latest/html/documentation/index.html#_safe_navigation_operator
In this case, if
phoneInstanceis null, then it doesn’t try to get thenameproperty and cause a NPE – it just sets the value of the field tag to null.