Prefer do end while creating blocks in ruby

We prefer using do..end instead of {} when using ruby blocks. {} is good when writing small one-liners or lambda, but using {} frequently makes code skewed as well as harder to read.

all_users.select {|user| user.is_admin? && user.is_team_member? && user.can_view_new_team_feature? }

Now, let’s see the do..end version:

all_users.select do |user|
  user.is_admin? && user.is_team_member? && user.can_view_new_team_feature?
end

It’s easier to read than the one-liner version, and can be further simplified as below:

all_users.select do |user|
  user.is_admin? &&
  user.is_team_member? &&
  user.can_view_new_team_feature?
end