cedric
10/12/2015, 2:58 AMcedric
10/12/2015, 2:58 AMcedric
10/12/2015, 2:59 AMflatMap
everything, and wrap callers and callees toojasoet-gdp
10/12/2015, 2:59 AMcedric
10/12/2015, 2:59 AMjasoet-gdp
10/12/2015, 3:00 AMcedric
10/12/2015, 3:00 AMx.canThrow()
x.operation() // guarantee to succeed, otherwise would have thrown
vs
val t = Try<...>
t.flatMap { it.operation() }
t.flatMap { it.operation2() }
jasoet-gdp
10/12/2015, 3:00 AMcedric
10/12/2015, 3:01 AMjasoet-gdp
10/12/2015, 3:02 AMreturn gradingRequestTry
.onFailure(throwable -> {
<http://logger.info|logger.info>(
"Exception when Save Question [" + throwable.getMessage() + "]",
throwable
);
})
.map(gradingRequest -> {
return new ResponseEntity<>(
new GradingControllerResult(gradingRequest.getId(), createdAt),
HttpStatus.OK
);
})
.orElse(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
jasoet-gdp
10/12/2015, 3:03 AMTry
monads for Java 8cedric
10/12/2015, 3:05 AMonError
onSuccess
basically allows you to not use Try
at al'jasoet-gdp
10/12/2015, 3:06 AMjasoet-gdp
10/12/2015, 3:07 AMjasoet-gdp
10/12/2015, 3:08 AMcedric
10/12/2015, 3:10 AMjasoet-gdp
10/12/2015, 3:13 AMjasoet-gdp
10/12/2015, 3:13 AMyasyd
10/28/2015, 8:43 AMyasyd
10/28/2015, 8:50 AMyasyd
10/28/2015, 8:52 AMyasyd
10/28/2015, 8:54 AMvoddan
10/28/2015, 11:23 AMvoddan
10/28/2015, 11:24 AMyasyd
10/28/2015, 11:39 AMyasyd
10/28/2015, 11:41 AMvoddan
11/02/2015, 8:14 AMval price = "${'$'}9.99"
is an awful way to type $
character into a string?voddan
11/02/2015, 8:15 AMval DS = '$'
in stdlibvoddan
11/02/2015, 8:16 AMval price = "$DS9.99"
, which is not ideal, but better if everybody know what DS
iswcaokaze
11/02/2015, 8:25 AM\$
bad? We can write val price = "\$9.99"