Method chaining allows us to apply multiple methods with less code.

For example, instead of using multiple definitions, like this:

with-labels = animals-table.build-column("labels", nametag)
cats = with-labels.filter(is-cat)
cats.order-by("age", true)

We can use method-chaining to write it all on one line, like this:

animals-table.build-column("labels", nametag).filter(is-cat).order-by("age", true)

Order Matters! The methods are applied in the order they appear. For example, trying to order a table by a column that hasn’t been built will result in an error.

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.