00.01.class" error?

Hi,

0.1.class results in float.
00.1.class results in error?

···

*******************
SyntaxError: compile error
(irb):5: no .<digit> floating literal anymore; put 0 before dot
00.1class
   ^
(irb):5: syntax error
00.1class
    ^
        from (irb):5
******************

as humans ignore any number of zeros before. why did ruby compiler
concerned abt it?. why this?. needs a fix to compiler :stuck_out_tongue:

sharma

--
Posted via http://www.ruby-forum.com/.

I think the problem is that floating point literals must be written
in base 10, unlike integer literals which can be written in octal.
In your case:

   00.1.class

the parser sees "00" as as 0 written as an octal constant. The parser
doesn't consider it as the start of a floating point value because
floating point values must be written in decimal. So after parsing
the "00" as an integer literal it sees ".1" as a no longer supported
floating point literal and complains.

Gary Wright

···

On Feb 24, 2007, at 2:33 PM, Sharma Chelluri wrote:

Hi,

0.1.class results in float.
00.1.class results in error?
*******************
SyntaxError: compile error
(irb):5: no .<digit> floating literal anymore; put 0 before dot
00.1class
   ^
(irb):5: syntax error
00.1class
    ^
        from (irb):5
******************

as humans ignore any number of zeros before. why did ruby compiler
concerned abt it?. why this?. needs a fix to compiler :stuck_out_tongue: