Download Getting Started with Scala 26-Jul-16

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Transcript
The require and assert methods

require and assert are methods that throw an exception when
their argument is false

require is used to document something that must be true in
order for the code to work



def sqrt(x: Double) = { require(x >= 0); ... }
require is often used at the beginning of a method
assert is used to document something that you “know” to be
true


takeCis554course
assert(languagesIKnow contains "Scala")
assert is often used as “executable documentation”