Mastering Enumerable, Part 1

Flashcard 7 of 7

How can we simplify this?

# Returns true when all users are administrators, false
# otherwise.
def all_are_admins?(users)
  all_admins = true

  users.each do |user|
    all_admins = all_admins && user.admin?
  end

  all_admins
end

Answer:

Reveal Answer