File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -2759,6 +2759,23 @@ condition](#safe-assignment-in-condition).
27592759 end
27602760 ```
27612761
2762+ * <a name="auto-release-resources"></a>
2763+ Use versions of resource obtaining methods that do automatic
2764+ resource cleanup when possible.
2765+ <sup>[[link](#auto-release-resources)]</sup>
2766+
2767+ ```Ruby
2768+ # bad - you need to close the file descriptor explicitly
2769+ f = File.open('testfile')
2770+ # ...
2771+ f.close
2772+
2773+ # good - the file descriptor is closed automatically
2774+ File.open('testfile') do |f|
2775+ # ...
2776+ end
2777+ ```
2778+
27622779* <a name="standard-exceptions"></a>
27632780 Favor the use of exceptions for the standard library over introducing new
27642781 exception classes.
You can’t perform that action at this time.
0 commit comments