Pages
core
Search
Entities
Result
Functions
Returns a new error result.
(Result.error("error")
|> Result.isError()) == true
Maps over the value of the result to an other result and flattens it.
(Result.error("error")
|> Result.flatMap(\item : String => Result::Ok(item + "1"))) == Result.error("error")
(Result.ok("ok")
|> Result.map(\item : String => Result::Ok(item + "1"))) == Result.ok("ok1")
Returns true if the result is an error.
(Result.error("error")
|> Result.isError()) == true
Returns true if the result is ok.
(Result.ok("ok")
|> Result.isOk()) == true
Joins two results together.
Result.join(Result::Ok(Result::Ok("Hello"))) == Result::Ok("Hello")
Result.join(Result::Err("Error") == Result::Err("Error")
Maps over the value of the result.
(Result.error("error")
|> Result.map(\item : String => item + "1")) == Result.error("error")
(Result.ok("ok")
|> Result.map(\item : String => item + "1")) == Result.ok("ok1")
Maps over the error of the result.
(Result.error("error")
|> Result.mapError(\item : String => item + "1")) == Result.error("error1")
(Result.ok("ok")
|> Result.mapError(\item : String => item + "1")) == Result.ok("ok")
Returns a new ok result.
(Result.ok("ok")
|> Result.isOk()) == true
Converts the result into a maybe.
(Result.ok("blah")
|> Result.toMaybe()) == Maybe.just("blah")
(Result.error("blah")
|> Result.toMaybe()) == Maybe.nothing()
Returns the value of the result or the default value if it's an error.
(Result.error("error")
|> Result.withDefault("a")) == "a"
(Result.ok("ok")
|> Result.withDefault("a")) == "ok"
Returns the error of the result or the default value if it's an ok.
(Result.error("error")
|> Result.withError("a")) == "error"
(Result.ok("ok")
|> Result.withError("a")) == "a"