3 ms·
> However, as we stopped generating primes at 100, the &strong subroutine would have received an undefined value when it requested that n+1th prime. When used a
by mikepurvis 7y ago
> However, as we stopped
generating primes at 100, the &strong subroutine would have received an
undefined value when it requested that n+1th prime. When used as a number,
that undefined value would convert to zero, so the average of 97's two prime
neighbours would be computed as (89+0)/2
I think I prefer Python's behaviour here, of just raising an OutOfRangeError, and not permitting NoneType to be coerced as an number.
- X6S1x6Okd1st 7y agoYeah a lot of languages don't fall for the undefined should silently give valid results thing
- donaldihunter 7y agoWell Damian's program actually reports "Use of uninitialized value of type Any in numeric context" which the programmer can choose to be a warning or an exception.