Reputation: 4925
I've just found a Ruby script that ends with the following lines:
exit
begin
end
To me, this looks pointless; but the developer who wrote the script was not normally one to do daft things.
Does this actually achieve anything? Some kind of fix for a known bug in Ruby, perhaps?
Upvotes: 0
Views: 79
Reputation: 91
As far as I can gather, no. it has no meaning and no function and no function. Nothing after exit is parsed (not entirely true [1], but in this case it is), and an empty begin end is not really useful either.
I would think it's a simple oversight during development/cleaning/refactoring. Even good developers make mistakes of course.
So the easiest way to be sure of his intentions, is to ask the author, of course!
[1] http://www.ruby-doc.org/core-1.9.3/Kernel.html#method-i-exit
Upvotes: 1