[swift-users] Design guidelines for computed property vs no-arg method

Jens Persson jens at bitcycle.com
Wed Jul 5 06:57:22 CDT 2017

Why is eg the BinaryInteger.signum() a method and not a computed property?

public protocol BinaryInteger … {
    /// Returns `-1` if this value is negative and `1` if it's positive;
    /// otherwise, `0`.
    /// - Returns: The sign of this number, expressed as an integer of the
    ///   type.
    public func signum() -> Self

The Swift API Design Guidelines doesn't say very much about computed
property vs method with no arguments, but it seems like signum() violates
them, no?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170705/20e01b2e/attachment.html>

More information about the swift-users mailing list