logoalt Hacker News

AdieuToLogicyesterday at 4:25 AM0 repliesview on HN

From the article:

  Here’s a little idiom that I haven’t really seen discussed 
  anywhere, that I think makes Rust code much cleaner and 
  more robust.
  
  I don’t know if there’s an actual name for this idiom; I’m 
  calling it the “block pattern” for lack of a better word.
This idiom has been discussed and codified in various languages for many years. For example, Scala has supported the same thusly:

  val foo: Int = {
    val one = 1
    val two = 2

    one + two
  }
Java (the language) has also supported[0] similar semantics.

Good to see Rust supports this technique as well.

0 - https://docs.oracle.com/javase/tutorial/java/javaOO/initial....