Files
grokking_algorithms/05_hash_tables/scala/02_check_voter.scala
chase-g 7d6d36ccb2 Adding Scala examples for Chapter 4 and Chapter 5 (#30)
* Add files via upload

* Update 01_countdown.scala

* Update 02_greet.scala

* Update 02_greet.scala

* Create scala

* Delete scala

* Add files via upload

* Add files via upload
2017-09-26 10:40:43 -07:00

12 lines
285 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)
}
}
check_voter("tom")
check_voter("mike")
check_voter("mike")