Skip to content

Commit

Permalink
Use a guard clause instead of wrapping the code inside a conditional …
Browse files Browse the repository at this point in the history
…expression
  • Loading branch information
sferik committed Sep 20, 2016
1 parent ed72cd6 commit ba74c8b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/t/rcfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ def [](username)

def find(username)
possibilities = Array(find_case_insensitive_match(username) || find_case_insensitive_possibilities(username))
if possibilities.size == 1
possibilities.first
else
raise(ArgumentError.new("Username #{username} is #{possibilities.empty? ? 'not found.' : 'ambiguous, matching ' + possibilities.join(', ')}"))
end
raise(ArgumentError.new("Username #{username} is #{possibilities.empty? ? 'not found.' : 'ambiguous, matching ' + possibilities.join(', ')}")) unless possibilities.size == 1
possibilities.first
end

def find_case_insensitive_match(username)
Expand Down

0 comments on commit ba74c8b

Please sign in to comment.