3 ms·
> The following deprecated methods are removed: Dir.exists? File.exists? These names were really elegant, I wonder why they were removed. Searching the web, th
by matheusmoreira 4y ago
> The following deprecated methods are removed: Dir.exists? File.exists?
These names were really elegant, I wonder why they were removed. Searching the web, the only explanation I can find is they were removed because they were deprecated. So why were they deprecated?
- tomstuart 4y agoFor better or worse, the convention in Ruby is to name methods in a second-person style [0], as if addressing the object directly: “file, do you `#exist?`”; “string, do you `#start_with?` foo?”. So, for consistency, `Dir.exist?` and `File.exist?` have been preferred for a long time. [0] https://bugs.ruby-lang.org/issues/9041#note-1 https://bugs.ruby-lang.org/issues/9041#note-1
- matheusmoreira 4y agoThat's true for File objects responding to an :exist? message. For the File class, I think exists? makes more sense. Anyway, no big deal. Happy to see Ruby getting nicer and nicer every update.