Hi.
In Ruby’s documentation I find this code to write in a file, the number 20 indicates that it must be written from byte number 20:
IO.binwrite("Test.txt", "0123456789", 20)
Okay, but I want to do something like this:
IO.binwrite("Test.txt", "0123456789", -1)
I mean, I want to start writing from the last byte, I’ve tried, and of course, it’s wrong.
An idea that occurs to me is to measure the size of the file in bytes and specify it with a variable:
file_size = File.size("Test.txt")
IO.binwrite("Test.txt", "0123456789", file_size)
But is that the only way I can do it?