When writing about ruby code we use:
Dogto represent the dog class#barkto represent an instan开发者_C百科ce method.newor::newto represent a class method
What's the convention for representing an instance of a class? dog would blend right in with the surrounding regular text.
That sounds about right. In Smalltalk, it is customary to use anArray, aString or aDog (even as parameter names in method declarations), which would translate to an_array, a_string or a_dog. However, that's not customary, and might look strange to an experienced Rubyist, who would expect to see ary, str and dog.
Note also that in general, the dot is only used in code examples for actual method calls. When talking about the method, always use # and :: for instance methods and singleton methods.
加载中,请稍侯......
精彩评论