Skip to content


fun with Ruby’s Enumerable

Ran into this on a legacy Rails app today:

1
<% for alpha_link in ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y'] -%>

And thought – Hmm, someone doesn’t understand Enumerable. Otherwise they might have done this:

1
<% ('A'..'Z').each do |alpha_link| -%>

Concise!

Posted in ruby.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.