Is there a one-line method of writing this each block in Ruby?
cats.each do |cat|
However, note that
Enumerable#each returns the same object you are iterating over (here
cats), so it only makes sense to use it to do some kind of side-effect within the block. You probably meant to collect the cat names, use
cat_names = cats.map(&:name)