Ruby Control Structures - Unless

  • + 2 comments

    This lesson is problematic, as it encourages a major ruby anti-pattern :(, namely, using conditionals such as if or unless inside of an iterator rather than using the built-in enumerables. While I realize it is intended as a gentle introduction, perhaps a lesson which does not include an iterator would be preferable?

    # using the build-in enumerables...
    def scoring(array)
      array.reject { |user| user.is_admin? }.each { |user| user.update_score }
    end