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
22942294FileUtils.rm_f(path)
22952295----
22962296
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+
22972313== Assignment & Comparison
22982314
22992315=== Parallel Assignment [[parallel-assignment]]
You can’t perform that action at this time.
0 commit comments