|
|
|
|
|
by josephg
149 days ago
|
|
> why a division operator, or an array access, doesn't return a `Result` type in nice languages such as Rust? Rust has standard library functions to do this, if you want. arr.get(index) returns an Option. Integer types have .checked_div for panic-free divide. Float already doesn’t panic on an invalid division - it just returns NaN or Infinity. |
|
(Just to be clear, I don't really propose that a language should offer only panic-free operations; I just think it's a nice thought experiment and discussion to have).