Difference between the access modes of the `File` object (ie. w+, r+)

前端 未结 4 1053
清酒与你
清酒与你 2020-12-02 09:47

When using files in Ruby, what is the difference between the r+ and w+ modes? What about the a+ mode?

4条回答
  •  粉色の甜心
    2020-12-02 10:13

    Answer: Both r+ and w+ we can read ,write on file but r+ does not truncate (delete) the content of file as well it doesn’t create a new file if such file doesn’t exits while in w+ truncate the content of file as well as create a new file if such file doesn’t exists.

提交回复
热议问题