Reputation: 10030
When writing about ruby code we use:
Dog
to represent the dog class#bark
to represent an instance method .new
or ::new
to represent a class methodWhat's the convention for representing an instance of a class? dog
would blend right in with the surrounding regular text.
Upvotes: 1
Views: 300
Reputation: 369488
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.
Upvotes: 3