코드 3-11 봐라, 이제 더 이상 else가 없다!
public UpdateResult UpdateCityIfChanged() {
if (Id <= 0) {
return UpdateResult.InvalidId; } bool isActive = db.IsPersonActive(Id); if (!isActive) { return UpdateResult.PersonInactive; } if (FirstName is null || LastName is null) { return UpdateResult.InvalidName; } string normalizedFirstName = FirstName.ToUpper(); string normalizedLastName = LastName.ToUpper(); string currentCity = db.GetCurrentCityByName( normalizedFirstName, normalizedLastName); if (currentCity == City) { return UpdateResult.CityDidNotChange; } bool success = db.UpdateCurrentCity(Id, City); if (!success) { return UpdateResult.UpdateFailed; } return UpdateResult.Success;
→ 반환 후에는 더 이상 코드가 실행되지 않는다.
}