import scala.
util .
{ Try, Success, Failure
}
val dividend
= Try
( Console.
readLine ( "Enter an Int that you'd like to divide:\n " ) .
toInt ) val divisor
= Try
( Console.
readLine ( "Enter an Int that you'd like to divide by:\n " ) .
toInt ) val problem
= dividend.
flatMap ( x
=> divisor.
map ( y
=> x/y
) ) println( "Result of " + dividend.get + "/" + divisor.get +" is: " + v)
Success( v)
println( "You must've divided by zero or entered something that's not an Int. Try again!" )
println( "Info from the exception: " + e.getMessage )
divide
}
}
divide
aW1wb3J0IHNjYWxhLnV0aWwue1RyeSwgU3VjY2VzcywgRmFpbHVyZX0KCmRlZiBkaXZpZGU6IFRyeVtJbnRdID0gewogIHZhbCBkaXZpZGVuZCA9IFRyeShDb25zb2xlLnJlYWRMaW5lKCJFbnRlciBhbiBJbnQgdGhhdCB5b3UnZCBsaWtlIHRvIGRpdmlkZTpcbiIpLnRvSW50KQogIHZhbCBkaXZpc29yID0gVHJ5KENvbnNvbGUucmVhZExpbmUoIkVudGVyIGFuIEludCB0aGF0IHlvdSdkIGxpa2UgdG8gZGl2aWRlIGJ5OlxuIikudG9JbnQpCiAgdmFsIHByb2JsZW0gPSBkaXZpZGVuZC5mbGF0TWFwKHggPT4gZGl2aXNvci5tYXAoeSA9PiB4L3kpKQogIHByb2JsZW0gbWF0Y2ggewogICAgY2FzZSBTdWNjZXNzKHYpID0+CiAgICAgIHByaW50bG4oIlJlc3VsdCBvZiAiICsgZGl2aWRlbmQuZ2V0ICsgIi8iKyBkaXZpc29yLmdldCArIiBpczogIiArIHYpCiAgICAgIFN1Y2Nlc3ModikKICAgIGNhc2UgRmFpbHVyZShlKSA9PgogICAgICBwcmludGxuKCJZb3UgbXVzdCd2ZSBkaXZpZGVkIGJ5IHplcm8gb3IgZW50ZXJlZCBzb21ldGhpbmcgdGhhdCdzIG5vdCBhbiBJbnQuIFRyeSBhZ2FpbiEiKQogICAgICBwcmludGxuKCJJbmZvIGZyb20gdGhlIGV4Y2VwdGlvbjogIiArIGUuZ2V0TWVzc2FnZSkKICAgICAgZGl2aWRlCiAgfQp9CgpkaXZpZGU=
compilation info
/opt/scala/bin/scalac: line 50: /dev/null: Permission denied
Main.scala:3: error: expected class or object definition
def divide: Try[Int] = {
^
Main.scala:18: error: expected class or object definition
divide
^
two errors found
spoj: The program compiled successfully, but Main.class was not found.
Class Main should contain method: def main(args: Array[String]).
stdout