On Sat, Nov 19, 2016 at 11:59 PM, Adrian Zubarev via swift-evolution <
[email protected]> wrote:
> From some older evolution-thread:
>
> extension SignedNumberType {
> var sign: Self {
> if self == (0 as Self) {
> return (0 as Self)
> } else if self > (0 as Self) {
> return (1 as Self)
> }
> return (-1 as Self)
> }
> }
> --
> Adrian Zubarev
> Sent with Airmail
>
Just played with this and it turns out that due to the implicit nature of
IntegerLiteralConvertible, you don't need any of the "as Self"s:
extension SignedNumber{
var sign: Self {
if self == 0 {
return 0
} else if self > 0 {
return 1
}
return -1
}
}
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution