LLM-generated Ruby code tends to reach for next inside .each loops. It works, but it’s not idiomatic. When you find yourself using next, there’s almost always a more expressive alternative using Enumerable methods. A Simple Example Consider this loop that collects names of active users: names = [] users.each do |user| next if user.inactive? names << user.name end The next if is doing filtering, but it doesn’t say filtering. It says “skip this one,” which forces the reader to mentally invert t...
No comments yet. Log in to discuss on the Fediverse