Linking together multiple Ruby Enumerable Methods in order to maintain concise, readable code

Daisy Chain Flower Crown
Daisy Chain Flower Crown
Daisy chain (Bellis perennis) CREDIT: RICHARD BLOOM/GETTY IMAGES

One thing that has bothered me as I learn different enumerable methods is that some methods, such as Select or Map, produce new arrays of information. To keep changing or accessing information that these arrays produce, you can assign each method to a variable and call the new variable as you go along, but that can grow cluttered very quickly. This is where Method Chaining (or Daisy Chaining) comes into play. Just like tying together multiple daisies end to end makes a chain, you can string together method after method in Ruby, and get a neat, concise package. …

Amanda Nikrant

Software Engineer in training at Flatiron School. Talk to me about coding, cats, or crossfit!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store