Kernel#sleep returns Float instead of Integer
time() internally, so it always returns Integer even if it called with Float.
I think returning Float is more useful than Integer.
(But I have no real use cases now.)
Updated by gabewild37 (Gabe Wild) 5 days ago
Hi, I don't know if anyone still wants this feature, but, since I wanted to get started contributing to ruby, I have implemented the following changes in my patch. Should an integer be entered into the function, the function acts like it used to. Ex: sleep(1) ==> 1, sleep(2) ==> 2. However, should a float be entered instead, the function will return a float. Ex: sleep(1.0) ==> 1.001077, sleep(2.2) ==> 2.202255. I did this by using gettimeofday() instead of time(), so the float returned is accurate to the microsecond. I also added some test code, and updated the documentation I found above the function in process.c to reflect my new changes. However, I think, instead of doing what I did, maybe making a new function or adding an optional flag could be better. Now that the return values are no longer rounded to integers, the changes in my patch could cause some backwards compatibility issues if someone is relying on rb_f_sleep to return an integer. Since I am new to both ruby and open source in general, any comments, suggestions, or improvements are appreciated.