Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
object DivideByZero extends Application {
|
||||
|
||||
def check(x: Int, y: Int): Boolean = {
|
||||
try {
|
||||
val result = x / y
|
||||
println(result)
|
||||
return false
|
||||
} catch {
|
||||
case x: ArithmeticException => {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println("divided by zero = " + check(1, 0))
|
||||
|
||||
def check1(x: Int, y: Int): Boolean = {
|
||||
import scala.util.Try
|
||||
Try(y/x).isFailure
|
||||
}
|
||||
println("divided by zero = " + check1(1, 0))
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue