Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix encoding

  • Loading branch information...
commit 406ee8b17b9778ab35730dcbc9ae7d44d3980db2 1 parent 65091d5
@demian0311 authored
View
2  src/test/scala/com/neidetcher/sfti/Chapter1Test.scala
@@ -131,7 +131,7 @@ class Chapter1Test {
// 2) In the Scala REPL, compute the square root of 3, and then square that value. By how much does the result differ from 3? (Hint: The res variables are your friend.)
assertEquals(3, math.sqrt(9).toInt)
- // 4) Scala lets you multiply a string with a numberÑtry out "crazy" * 3 in the REPL. What does this operation do? Where can you find it in Scaladoc?
+ // 4) Scala lets you multiply a string with a numberÑtry out "crazy" * 3 in the REPL. What does this operation do? Where can you find it in Scaladoc?
// http://www.scala-lang.org/api/current/index.html#scala.collection.immutable.StringOps
assertEquals("crazy crazy crazy ", "crazy " * 3)
View
13 src/test/scala/com/neidetcher/sfti/Chapter4Test.scala
@@ -5,7 +5,7 @@ import org.junit.Assert._
class Chapter4Test {
/** Fixed-Length Arrays */
- @Test def four_1 {
+ @Test def one {
// this creates an immutable map
val scores = Map("Alice" -> 10, "Bob" -> 3, "Cindy" -> 8)
println("scores: " + scores)
@@ -31,6 +31,7 @@ class Chapter4Test {
assertEquals(None, result2)
}
+ /** Updating Map Values */
@Test def three {
val scores = collection.mutable.Map("Bob" -> 5)
@@ -42,6 +43,16 @@ class Chapter4Test {
scores -= "Fred"
println("scores: " + scores)
+ // we removed Fred
+ assertEquals(Map("Bob" -> 10, "Ted" -> 5, "Jim" -> 6), scores)
+ }
+
+ /** Iterating over Maps*/
+ @Test def four {
+ val map = Map("Bob" -> 10, "Ted" -> 5, "Jim" -> 6)
+
+ for ((k, v) <- map) { println(k + "->" + v) }
+
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.