In Ruby, Output of puts 07 is 7. But output of puts 08 is error. Why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

In Ruby, Output of puts 07 is 7. But output of puts 08 is error. Why?

17th Sep 2017, 1:22 PM
Uttam
Uttam - avatar
2 Answers
+ 7
0b1110 will output 14 bc if start with 0b following number must be binary 0xff will output 255 bc if start with 0x following number must be hex So how about 07? if start with 0 and 0-7 It mean start to do octal number 07 = 7 016 = 14 anyway search google my grammar bad!
17th Sep 2017, 1:27 PM
Yanothai Chaitawat
Yanothai Chaitawat - avatar