Compare a variable storing a directory path with the current directory : chdir « File Directory « Ruby






Compare a variable storing a directory path with the current directory


ruby_progs = "/Users/Ruby"

if not Dir.pwd == ruby_progs
  Dir.chdir ruby_progs
end

 








Related examples in the same category

1.To change directory within a Ruby program, use Dir.chdir: