Hacker News new | past | comments | ask | show | jobs | submit login

In Swift:

   func myAnd(lhs: Bool,
              rhs: @autoclosure () -> Bool) -> Bool
   {
     return lhs ? rhs() : false
   }
(Heavily inspired by https://medium.com/swift-programming/facets-of-swift-part-5-.... Not tested; any bugs likely are mine)



I don't know Swift, but it seems[0] that it is not possible to apply this with multiple arguments, like in the original example (e.g. (and a b c d)).

[0] https://stackoverflow.com/questions/29750244/variadic-autocl...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: