From: najamelan@... Date: 2016-07-19T19:25:04+00:00 Subject: [ruby-core:76451] [Ruby trunk Feature#7361] Adding Pathname#touch Issue #7361 has been updated by Naja Melan. I prefer something like (warning, untested code): ~~~ ruby def touch( subPath = '', **options ) path = @path ret = self if directory? ret = join subPath path = ret.to_path end FileUtils.touch( path, **options ) ret end ~~~ lets you do: ~~~ ruby mydir.touch 'somefile' ~~~ I think touch is a good name because everybody already knows it and it's what people will try out spontaneously before even looking in the docs why it doesn't work. Joel Spolsky [explains quite well](http://www.joelonsoftware.com/uibook/fog0000000249.html) why this is a good thing. ---------------------------------------- Feature #7361: Adding Pathname#touch https://bugs.ruby-lang.org/issues/7361#change-59696 * Author: Alexander E. Fischer * Status: Rejected * Priority: Normal * Assignee: Akira Tanaka ---------------------------------------- Pathname has an #mkdir method to create a directory at the path, but does not have a #touch method to create an empty file at that path. There were numerous cases where I had to fallback to using new_file = Pathname.new('location/for/new/file') FileUtils.touch(new_file) instead of simply being able to use: new_file.touch I would like to add this method. If you like it, let me know. I will provide a patch then. -- https://bugs.ruby-lang.org/ Unsubscribe: