Ruby/Przetwarzanie wyjątków: ensure: Różnice pomiędzy wersjami
Usunięta treść Dodana treść
m nav |
Szymon wro (dyskusja | edycje) Nie podano opisu zmian |
||
Linia 1:
== Przetwarzanie wyjątków: ensure ==
Może się tak zdarzyć, że potrzebna jest
There may be cleanup work that is necessary when a method finishes its work. Perhaps an open file should be closed, buffered data should be flushed, etc. If there were always only one exit point for each method, we could confidently put our cleanup code in one place and know that it would be executed; however, a method might return from several places, or our intended cleanup code might be unexpectedly skipped because of an exception.
|