airbnb / ruby

Ruby Style Guide

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Method chaining

kiriakosv opened this issue · comments

Hello, is there a rule regarding method chaining? For example:

person = Person.new

# bad
person.name("Peter").age(21).introduce

# good
person.name("Peter")
      .age(21)
      .introduce

If not, can I make a pull request to add one?

@kiriakosv Thank you for offering to contribute.

We allow method chaining within the same line. And we generally put the dot at the end of the line when we break it up across lines.