From e8dd37d9b7fd35f138ba62d1197598d8d207e75b Mon Sep 17 00:00:00 2001 From: "Abinoam P. Marques Jr" Date: Sun, 2 Jul 2017 01:43:25 -0300 Subject: Use a guard clause --- lib/highline/question_asker.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/highline/question_asker.rb b/lib/highline/question_asker.rb index 433d709..b919cb0 100644 --- a/lib/highline/question_asker.rb +++ b/lib/highline/question_asker.rb @@ -67,14 +67,14 @@ class HighLine verify_match = question.verify_match answers = [] - loop do # when verify_match is set this loop will repeat until unique_answers == 1 + # when verify_match is set this loop will repeat until unique_answers == 1 + loop do answers = gather_answers_based_on_type - if verify_match && (@highline.send(:unique_answers, answers).size > 1) - explain_error(:mismatch) - else - break - end + break unless verify_match && + (@highline.send(:unique_answers, answers).size > 1) + + explain_error(:mismatch) end verify_match ? @highline.send(:last_answer, answers) : answers -- cgit v1.2.1