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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user