Open
Description
Strictly speaking, this one is still correct:
isValid { _address.count == 4 && _address.all {|n| n is Num && n >= 0 && n <= 255 }}
But the way how the array is filled assumes all parts of the string are in decimal format:
construct fromString(s) {
_address = s.split(".").map { |n| Num.fromString(n) }
}
However an IP address like this: 168.011.012.013 is not decimal. The 3 parts starting with a 0 are supposed to be interpreted as octal numbers.
So strictly speaking you construct a "valid IP address" but it is not the one, a proper IP stack would construct.
No worries: that usage is extremely rare ... and there are (plenty?) IP stacks that do it wrong, too :P
Metadata
Metadata
Assignees
Labels
No labels
Activity