SooDesuNe
SooDesuNe

Reputation: 10030

Ruby notation conventions

When writing about ruby code we use:

What's the convention for representing an instance of a class? dog would blend right in with the surrounding regular text.

Upvotes: 1

Views: 300

Answers (1)

Jörg W Mittag
Jörg W Mittag

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

Related Questions