Files
grokking_algorithms/05_hash_tables/scala/02_check_voter.scala
Ian Shiundu fb0d9dccfd Update check_voter method for Scala (#79)
* add IDE specific git ignore files

* add log for new user
2018-07-18 16:03:54 -07:00

13 lines
315 B
Scala

import scala.collection.mutable
val voted = mutable.Map[String, Boolean]()
def check_voter(name: String): Unit = {
if(voted.exists(_ == (name,true))){
println("kick them out!")
} else{
voted += (name -> true)
println("let them vote!")
}
}
check_voter("tom")
check_voter("mike")
check_voter("mike")