File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -2294,6 +2294,22 @@ end
2294
2294
FileUtils.rm_f(path)
2295
2295
----
2296
2296
2297
+ === Null Devices [[null-devices]]
2298
+
2299
+ Use the platform independent null device (`File::NULL`) rather than hardcoding a value (`/dev/null` on Unix-like OSes, `NUL` or `NUL:` on Windows).
2300
+
2301
+ [source,ruby]
2302
+ ----
2303
+ # bad - hardcoded devices are platform specific
2304
+ File.open("/dev/null", 'w') { ... }
2305
+
2306
+ # bad - unnecessary ternary can be replaced with `File::NULL`
2307
+ File.open(Gem.win_platform? ? 'NUL' : '/dev/null', 'w') { ... }
2308
+
2309
+ # good - platform independent
2310
+ File.open(File::NULL, 'w') { ... }
2311
+ ----
2312
+
2297
2313
== Assignment & Comparison
2298
2314
2299
2315
=== Parallel Assignment [[parallel-assignment]]
You can’t perform that action at this time.
0 commit comments