From a23e1fa400a7b6bbdda5a37546c9cd1e2d04220b Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Sun, 25 Aug 2024 00:59:31 +0000 Subject: [PATCH] Update Examples --- Examples.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Examples.md b/Examples.md index 2afed91..170af29 100644 --- a/Examples.md +++ b/Examples.md @@ -539,10 +539,38 @@ Or here. ``` +fn main() { + let long_lived_binding = 1; + + { + let short_lived_binding = 2; + println!("inner short: {}", short_lived_binding); + } + + // Error! `short_lived_binding` doesn't exist in this scope + println!("outer short: {}", short_lived_binding); + // FIXME ^ Comment out this line + + println!("outer long: {}", long_lived_binding); +} ``` ``` +fn main + let long_lived_binding = 1 + + scope //! Husht needs a keyword; other choices exist + let short_lived_binding = 2 + println! "inner short: {}", short_lived_binding + + // Error! `short_lived_binding` doesn't exist in this scope + println! "outer short: {}", short_lived_binding + // FIXME ^ Comment out this line + + println! "outer long: {}", long_lived_binding + + ```