Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,10 @@ object SyntacticConveniences extends ScalaTutorialSection {
*/
def typeAlias(res0: Either[String, (Int, Int)]): Unit = {
type Result = Either[String, (Int, Int)]
def divide(dividend: Int, divisor: Int): Result =
def divide(dividend: Int, divisor: Int): Result = {
if (divisor == 0) Left("Division by zero")
else Right((dividend / divisor, dividend % divisor))
}
divide(6, 4) shouldBe Right((1, 2))
divide(2, 0) shouldBe Left("Division by zero")
divide(8, 4) shouldBe res0
Expand Down