News for hackers. Stuff that matters.
Re:How I went about learning Rust by nailer on Friday July 15, 2022 @02:16PM (#32111188)
> I.e. if you pass maybe-scores to something that computes the mean, you'll get a compiler error. The writer of the mean function doesn't need to care you've overloaded an error value onto your numbers.

If I pass a null into something that calculates an average, taking numbers, the TS compiler will complain now. The writer of mean() (assuming mean() is typed) doesn’t have to know anything about my code.

Re:How I went about learning Rust by groby_b on Friday July 15, 2022 @05:48PM (#32113167)
This only works for non-sentinels. I.e. if "-1" happens to be the value indicating NoScore, I don't think the TS compiler can catch that?
Re:How I went about learning Rust by nailer on Sunday July 17, 2022 @01:07PM (#32128684)
Nobody is discussing using a magic number for null, nor is that an accepted practice in TS.