From c849e75041fb269b2667551f66361a348910957a Mon Sep 17 00:00:00 2001 From: Timo J Date: Sun, 8 Dec 2019 12:03:15 +0100 Subject: [PATCH] More concise Rubyish code. Hash key checking is not necessary in this case. If a key doesn't exist in a Hash, Ruby returns nil by default and nil is falsy. Hash key checking would only be necessary if the Hash had been set up with a default value. --- 05_hash_tables/ruby/02_check_voter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/05_hash_tables/ruby/02_check_voter.rb b/05_hash_tables/ruby/02_check_voter.rb index 0832e52..b13f50b 100644 --- a/05_hash_tables/ruby/02_check_voter.rb +++ b/05_hash_tables/ruby/02_check_voter.rb @@ -3,7 +3,7 @@ @voted = {} def check_voter(name) - if @voted.key?(name) && @voted[name] + if @voted[name] puts "kick them out!" else @voted[name] = true