Ruby conditions + multiple ORs
Code refactoring for multiple OR conditions, Here is an example of weird looking conditional statement
Option 1
if name.blank? || surname.blank? || nickname.blank? || aka.blank? ... endLets try and refactor this
Option 1
if [name, surname, nickname, aka].any? { |field| field.blank? } ... endOption 2
if [name, surname, nickname, aka].any?(&:blank?) ... end
Comments
Post a Comment