On Jul 15, 8:46 pm, Nobuyoshi Nakada <n... / ruby-lang.org> wrote:
> > On another note, String#oct allows the base to be changed by a base
> > prefix:
> > Is this by design?
>
> Yes, it's intentional.

OK, any chance we can adjust the RI documentation?

Currently it is:

     Treats leading characters of _str_ as a string of octal digits
     (with an optional sign) and returns the corresponding number.
     Returns 0 if the conversion fails.

        "123".oct       #=> 83
        "-377".oct      #=> -255
        "bad".oct       #=> 0
        "0377bad".oct   #=> 255

Let me propose changing it to:

     Treats leading characters of _str_ as a string of octal digits
     (with an optional sign) and returns the corresponding number.
     Non-octal bases are supported via "0x" style base prefixes.

        "123".oct       #=> 83
        "-377".oct      #=> -255
        "bad".oct       #=> 0
        "0377bad".oct   #=> 255
        "0xff".oct      #=> 255
        "0b1111".oct    #=> 15
        "0d84".oct      #=> 84

Thank you!