I'm wondering if I can easily have an if statement somehow here:
public Object[] tableItemFromVisit(Visit visit, boolean editable) {
return new Object[] {
visit.getIdVisit(),
visit.getProfession().getProfessionName(),
visit.getSpiProfessional().getFullName(),
RegularFunctions.getTimeFormat().format(visit.getVisitDate()),
RegularFunctions.toNormalCapitalizedText(visit.getVisitState()
.toString()), visit.getReason(),
if (editable) { "Edit" },
};
}
How is this structure even called? An array specification or what? Anyway if the variable "editable" is true, it has to have an "Edit" string, if it's false, it doesn't need anything... Obviously I don't want to write two return statements that are way too similar to each other...
if
is a statement and cannot be used as an Expression.?:
is an expression: of course, all expression must evaluate to a value. – Andes