Except in that case true isn’t a Bool but an NSNumber, which is why you can initialize an Int from it. It seems trivially easy to add an Int extension to do what you want though.
Jon > On Nov 20, 2016, at 10:48 PM, Rick Mann via swift-users > <[email protected]> wrote: > > It seems I can't do this: > > let r = Int(a > b) > > but I can do it with a literal: > > let r = Int(true) > > I'd like to do this to implement signum without branching, but perhaps that's > not possible. > > -- > Rick Mann > [email protected] > > > _______________________________________________ > swift-users mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-users _______________________________________________ swift-users mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-users
