i am doing some scala exercises using the resources from scala Exercises and i have found that intecept command is not working.
MacBook-Pro-Retina-de-Alonso:~ aironman$ scala
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val myMap = Map("OH" -> "Ohio", "WI" -> "Wisconsin", "IA" -> "Iowa")
myMap: scala.collection.immutable.Map[String,String] = Map(OH -> Ohio, WI -> Wisconsin, IA -> Iowa)
scala> var blewWithException = true
blewWithException: Boolean = true
scala> intercept[NoSuchElementException] {
| myMap("MI")
| blewWithException = false
| }
<console>:13: error: not found: value intercept
intercept[NoSuchElementException] {
^
scala>
My excuses if this question is already solved, but the system is not retrieving me the solution.
intercept method is a part of a test library, you have to download ScalaTest jar and extend Assertions trait to use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With