Q. How do you open a file in Ruby in write mode, creating it if it does not exist?

  • (A) File.create("filename.txt", "w")
  • (B) File.write("filename.txt", "w")
  • (C) File.open("filename.txt", "w")
  • (D) File.new("filename.txt", "w")
πŸ’¬ Discuss
βœ… Correct Answer: (C) File.open("filename.txt", "w")

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
206
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
94%
Success Rate