<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">For me, a noun is a property, a verb is a method. So `foo` is a property, `calculateFoo()` is a method.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">For your specific question, `func signum() -> Self` returns `Self`, which can't be used in property. </div><div class="gmail_default" style="font-family:georgia,serif">`var signum:Self { return self }` will generate an error "'Self' is only available in a protocol or as the result of a method in a class". So computed property can't be used here.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhao Xin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 5, 2017 at 7:57 PM, Jens Persson via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Why is eg the BinaryInteger.signum() a method and not a computed property?<br></div><div><br></div><div>public protocol BinaryInteger … {<br></div><div><div> /// Returns `-1` if this value is negative and `1` if it's positive;</div><div> /// otherwise, `0`.</div><div> ///</div><div> /// - Returns: The sign of this number, expressed as an integer of the same</div><div> /// type.</div><div> public func signum() -> Self</div></div><div>}</div><div><br></div><div>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?<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>/Jens</div></font></span></div>
<br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>