tainbox icon indicating copy to clipboard operation
tainbox copied to clipboard

Fix converting in Integer type

Open AnotherRegularDude opened this issue 4 years ago • 0 comments

From documentation about Kernel#Integer:

If arg is a String, when base is omitted or equals zero, radix indicators (0, 0b, and 0x) are honored.

So, usually, when a string is converted to a number, assumed that the string has a decimal number system But now:

class Test
  include Tainbox

  attribute :age, :Integer
end

t = Test.new(age: "012")
p t.age #=> 10

AnotherRegularDude avatar Aug 18 '19 17:08 AnotherRegularDude