<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><span></span>One area of swift that is really not clear to me is when you want to use the type of a class, struct, enum, etc as a value.&nbsp;</div><div><br></div><div>Metatyping is explained here:&nbsp;<a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/doc/uid/TP40014097-CH31-XID_1022">https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Types.html#//apple_ref/doc/uid/TP40014097-CH31-XID_1022</a></div><div><br></div><div>Example:&nbsp;<ol class="code-lines" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none;"><li style="text-indent: 0px; border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; list-style-type: none;"><code class="code-voice" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;"><font face="UICTFontTextStyleTallBody"><span class="kt" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">let</span> <span class="vc" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">metatype</span><span style="background-color: rgba(255, 255, 255, 0);">: </span><span class="n" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">SomeClass</span><span style="background-color: rgba(255, 255, 255, 0);">.</span><span class="vc" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Type</span><span style="background-color: rgba(255, 255, 255, 0);"> =&nbsp;SomeClass.</span><span class="kt" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">self</span></font></code></li></ol><div><br></div><div>Is there a reason why this isn't&nbsp;<span style="background-color: rgba(255, 255, 255, 0);">SomeClass.</span>type? Everywhere in the document this is explained as returning the type yet it's using a postfix self to access the type.&nbsp;</div><div><br></div><div>I propose changing the postfix self to something more obvious like "type"</div><div><br></div><div>Going back to the example:</div><div><ol class="code-lines" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; counter-reset: li 0; line-height: 1.6em; list-style: none;"><li style="text-indent: 0px; border-width: 0px 0px 0px 18px; border-left-style: solid; border-left-color: transparent; margin: 0px; outline: 0px; padding: 0px 10px 0px 0px; vertical-align: baseline; list-style-type: none;"><code class="code-voice" style="border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline; word-wrap: break-word;"><font face="UICTFontTextStyleTallBody"><span class="kt" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">let</span> <span class="vc" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">metatype</span><span style="background-color: rgba(255, 255, 255, 0);">:&nbsp;SomeClass.</span><span class="vc" style="background-color: rgba(255, 255, 255, 0); border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Type</span><span style="background-color: rgba(255, 255, 255, 0);"> =&nbsp;SomeClass.type</span></font></code></li></ol><div><br></div></div><div>Several reasons why I think this is better:</div><div>1. Postfix self is not obvious as an option as you never see a postfix self anywhere else&nbsp;</div><div>2. "self" does not clearly explain that the type is being returned&nbsp;</div><div>3. ObjC programmers are familiar with accessing the class type by sending the "class" method to the class type. In this case it needs to work on structs and enums, so a "type" method would make more sense.&nbsp;</div><div>4. Instances have a dynamicType method. For consistency, classes, structs, etc., should have a type method</div><div><br></div><div>Any other suggestions would be welcome.&nbsp;</div><div><br></div><div>Brandon&nbsp;</div><span></span><br><span>Sent from my iPad</span><br></div></body></html>