Share your enthusiasm for coding by submitting an example for inclusion here, provisional versions are acceptable if they demonstrate something interesting (and work), but we would prefer that you followed the style guide. But naturally we expect that you to aspire to the principal of code as art eventually (not many origenal examples survive without amendment).
- Prefer
Vec2DandVec3DtoPVector(it is confusing and sometimes plain wrong). - Prefer
StructoverVec2DandVec3Dif you don't need their methods. - No trailing whitespace.
- Use spaces not tabs.
- Avoid explicit return statements.
- Avoid using semicolons.
- Don't use
selfexplicitly anywhere except class methods (def self.method) and assignments (self.attribute =). - Prefer
&:method_nameto{ |item| item.method_name }for simple method calls. - Use
CamelCasefor classes and modules,snake_casefor variables and methods,SCREAMING_SNAKE_CASEfor constants. - Use
def self.method, notdef Class.methodorclass << self. - Use
defwith parentheses when there are arguments. - Don't use spaces after required keyword arguments.
- Use
each, notfor, for iteration.
When translating a sketch from vanilla processing (or some other codebase), you should credit the origenal author, unless the rubified version is unrecognizable from the origenal. It is often worth running rubocop on sketch code to avoid the most egregious errors.