Type Safely

Type Safely

Use a Do Block Without a Catch Block

Daily Coding Tip 266

Type Safely's avatar
Type Safely
Mar 15, 2023
∙ Paid
text
Photo by Brett Jordan on Unsplash

It might seem pointless to create a do block on its own, because the lines of code will be run sequentially.

But it’s useful to have a very restrictive view of scope in an app. Whatever happens in a do block stays in that do block, which includes the creation of any variables. This is useful when you don’t want to get con…

User's avatar

Continue reading this post for free, courtesy of Type Safely.

Or purchase a paid subscription.
© 2026 Type Safely · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture