From 1590c05af9724f54df92b7be4fc8f5099c48a573 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Mon, 7 Jul 2025 14:39:19 +0200 Subject: [PATCH] docs: fix Option example --- README.md | 4 ++-- tools/apigen/theme/pages/index.latte | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5cef420..94a6109 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Read the [documentation](https://doc.maybe.texthtml.net) full API description, d * @return Option */ function divide(float $numerator, float $denominator): Option { - return match ($denomintor) { + return match ($denominator) { 0.0 => Option\none(), default => Option\some($numerator / $denominator), }; @@ -40,7 +40,7 @@ $result = divide(2.0, 3.0); // Pattern match to retrieve the value if ($result->isSome()) { // The division was valid - echo "Result: {$option->unwrap()}"; + echo "Result: {$result->unwrap()}"; } else { // The division was invalid echo "Cannot divide by 0"; diff --git a/tools/apigen/theme/pages/index.latte b/tools/apigen/theme/pages/index.latte index d7c6887..1619f9f 100644 --- a/tools/apigen/theme/pages/index.latte +++ b/tools/apigen/theme/pages/index.latte @@ -41,9 +41,9 @@ * @param Option */ function divide(float $numerator, float $denominator): Option { - return match ($denomintor) { + return match ($denominator) { 0.0 => Option\none(), - _ => Option\some($numerator / $denominator) + default => Option\some($numerator / $denominator), }; } @@ -53,7 +53,7 @@ $result = divide(2.0, 3.0); // Pattern match to retrieve the value if ($result instanceof Option\Some) { // The division was valid - echo "Result: {$option->unwrap()}"); + echo "Result: {$result->unwrap()}"; } else { // The division was invalid echo "Cannot divide by 0";