Looking for Good-Tutorials Moderators
Apr 10, 2009 — 19 comments
Certainly. The square brace shorthand is meant for this purpose as well though so personally I do not see any reason not to use it, however I agree that more readable alternatives are available
While these are valid examples, they seem a little bit PHP-y, from my point of view. As you get more into Ruby, you tend to place a lot of value on typical Ruby idioms of development. For example, a lot of these could use Ruby's String class, which seems (to me, at least) to be a more appropriate way of accomplishing these tasks. Using .include?('string') instead of the array-based approach, for example, or one of the many ways to use regexes on a String.