CC: Tweaked

CC: Tweaked

59M Downloads

ReadHandle.readAll behaviour differs from documentaiton

sashafiesta opened this issue ยท 2 comments

commented

Minecraft Version

1.20.1

Version

1.109.6

Details

The documentation says that the ReadHandle.readAll (docs) returns nil when the cursor is at the end of the file.
In fact, in this case, the method returns an empty string.
So

handler.readAll()
print(type(handler.readAll()))

Prints string, when it should print nil

So there's probably a mistake in the documentation or a bug.

commented

ReadWriteHandle.readAll seems to be affected too

commented

Thanks for the report! I have corrected the docs in 34a2fd0.

Binary handles (rb) used to return nil if they reached the end of the file, while text handles (r) returned an empty string. As of the unification of file handles in CC:T 1.109, both will always return an empty string. This matches the behaviour of PUC Lua, and I think generally is less confusing.