4 ms·
Can you also please explain what the "||" is doing? That looks really weird to me coming from Swift and don't see it in the docs. edit: thanks all, should have
by trevor-e 6y ago
Can you also please explain what the "||" is doing? That looks really weird to me coming from Swift and don't see it in the docs.
edit: thanks all, should have known it was a lambda :D, in Swift we can omit this. My first thought seeing "||" was some type of OR logic since it's in the context of if/else
- varajelle 6y agoIt is a lambda function with no parameters. The argument of then() is a function which is evaluated only if the bool is true.
- Sharlin 6y agoRust lambdas look like this: |ar,gs| expr So `|| expr` is just a lambda function that takes no arguments and evaluates to `expr`.
- deleted 6y ago[deleted]
- laszlokorte 6y agoempty parameter list of a closure. rust: |x| x+x swift: {x in x+x} rust: || 42 swift: { 42 }
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]