When is File.join useful?

There is another, subtle difference:

File.join('foo','bar')
#=> "foo/bar"
['foo','bar'].join("https://stackoverflow.com/")
#=> "foo/bar"

But, if you pass an argument already ending with / (which is quite often when working with paths), you won’t have two slashes in the result:

File.join('foo/','bar')
#=> "foo/bar"
['foo/','bar'].join("https://stackoverflow.com/")
#=> "foo//bar"

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)