Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#make_link
(::String | ::Pathname | ::_ToStr old) -> ::Integer
make_link(path) → 0
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1733
def make_link(old) File.link(old, @path) end
Not available on some systems.
Creates a new entry at the path in self for the existing entry at path using a hard link:
Example
File.write('doc/t.tmp', 'foo') Pathname('lib/u.tmp').make_link('doc/t.tmp') File.read('lib/u.tmp') # => "foo" File.write('lib/u.tmp', 'bar') File.read('doc/t.tmp') # => "bar" File.delete('doc/t.tmp') File.read('lib/u.tmp') # => "bar" File.delete('lib/u.tmp')
Raises an exception if the entry at the path in self exists.