Comment Comment by greenhouse_gas My issue with Monads (and why I like kotlin and swift nullable types) is that it allows the compiler to infer nullability like the following code:fun f(a1: Int?, a2: Int?): Int { if (a1 == null || a2 == null) { return 0 } //now you can do something like return a1+a2 }In contrast, if it didn't, the code would look like:fn func1(q: Option<i32>, z: Option<i32>) -> i32 { if let Some(q_in) = q { if let Some(z_in) = z { return q_in + z_in } } return 0 }Note the deeply nested parenthesis. parent greenhouse_gas 8 years ago
fun f(a1: Int?, a2: Int?): Int {
}In contrast, if it didn't, the code would look like:
fn func1(q: Option<i32>, z: Option<i32>) -> i32 {
}Note the deeply nested parenthesis.