We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ff3ce80 commit 7b2b7b4Copy full SHA for 7b2b7b4
README.adoc
@@ -2294,6 +2294,22 @@ end
2294
FileUtils.rm_f(path)
2295
----
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 specfic
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
2313
== Assignment & Comparison
2314
2315
=== Parallel Assignment [[parallel-assignment]]
0 commit comments