From: Gary Wright Date: 2007-12-19T12:00:13+09:00 Subject: Re: String#% bug on Windows? On Dec 18, 2007, at 8:54 PM, Nobuyoshi Nakada wrote: > Hi, > > At Wed, 19 Dec 2007 03:59:32 +0900, > Berger, Daniel wrote in [ruby-core:14139]: >> # test.rb >> puts "%x" % "0_3_7_7" >> >> On Linux the above snippet returns 'ff'. On Windows I get test.rb: >> 1:in >> `%': invalid value for Integer: "0_3_7_7" (ArgumentError) > > What are the versions? Kernel#Integer works more strictly > recently, underscores are no longer allowed between radix > prefix and trailing digits. > > In this case, preceeding "0" was treated as octal radix prefix, > however it seems unexpected behavior. It doesn't seem unexpected to me. I would expect the following expressions to all evaluate to the same fixnum: 0_377 "0_377".to_i Integer("0_377") 0377 "0377".to_i Integer("0377") Perhaps an argument can be made that to_i and Integer shouldn't recognize radix prefixes or underscores but it would seem unexpected for to_i and Integer to only recognize one or the other. All or nothing I say. Gary Wright