The following code takes a fixnum and transforms it to a string.
If the fixnum is a one digit number, a prefix will be added. The
code is useful to display numbers in a "digital clock" way.
def format_to_2digits (no)
# Precondition: no.type == Fixnum
str = no.to_s
str[0, 0] = "0" if str.size == 1 else str
end
The last line of the method is a bit strange but the code works
fine (I was just experimenting). But while executing the code
I got the following warning from the interpreter:
test.rb:74: warning: else without rescue is useless
Is there something wrong with my code? Or is this a bug?
My Ruby version in case this is relevant:
ruby 1.6.2 (2000-11-04) [i386-mingw32]
Regards,
Paul.