00.01.class" error?

S

Sharma Chelluri

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 :p

sharma
 
G

Gary Wright

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 :p

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Ruby Error Question 1
:IRB Bug 1
Symbol#inspect bug? 14
ruby and library paths 7
(Encryption Package) error: cannot find symbol symbol: class BaseNCode 6
Syntax error 1
Net::HTTP and numerical adress 3
Method error 0

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top