Actions
Bug #17395
closedKernel::Integer does not raise ArgumentError for strings with whitespace padding
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin18]
Description
According to the Kernel::Integer docs, ArgumentError should be raised if the argument is a String and doesn't conform with numerical representation. However, it appears that Kernel::Integer does not raise ArgumentError when a string contains leading or trailing whitespace.
Ruby Version: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin18]
Reproduce Steps:
Integer(" 1")
Integer("1 ")
Actual Results:
both parse to a valid Integer, 1, no exception is raised.
Expected Results:
both should raise ArgumentError because they contain non-numerical characters
Updated by nobu (Nobuyoshi Nakada) about 4 years ago
- Status changed from Open to Closed
Applied in changeset git|a039dc018ccf34e217f767eac500b9400c58f069.
[DOC] Described "numeric representation" more precisely [ci skip]
[Bug #17395]
Actions
Like0
Like0