Case expressions is a feature introduced in the May 2010 release.
It makes it possible to use case in an expression instead of a standalone statement. Instead of statements, case requires a (single) expression for each element and its else:
method ConsoleApp.ValuesText(aValue: Integer): string; begin result := 'text: ' + case aValue of 0: 'none'; 1: 'one'; 2: 'two'; 3..5 : 'several'; else 'many'; end;
If the else case is omitted from the case, it defaults to nil (nullable type for value types, else reference type).
The result type of a case expression is the closest type that fits all members. For integers and doubles, it picks the type that can hold all values used (int + double -> double; int + int64 -> int64).