Why is 032 different than 32 in Ruby?

前端 未结 4 631
一生所求
一生所求 2021-01-07 10:17

I have noticed Ruby behaves differently when working with 032 and 32. I once got syntax errors for having 032 instead of just 32 in my code. Can someone explain this to me?

4条回答
  •  误落风尘
    2021-01-07 10:38

    If you start a number with 0 (zero), ruby treats it as an octal, so you normally don't want the zero. You'll have to be more specific about the syntax error.

提交回复
热议问题