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
This commit is contained in:
chase-g
2017-09-26 13:40:43 -04:00
committed by Aditya Bhargava
parent d76298722f
commit 7d6d36ccb2
7 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import scala.collection.mutable
val book = mutable.Map[String, Double]()
book += ("apple" -> 0.67)
book += ("milk" -> 1.49)
book += ("avocado" -> 1.49)
println(book)

View File

@@ -0,0 +1,12 @@
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")