News for hackers. Stuff that matters.
Re:Scala's Option monad versus null-conditional operator in C# by wantreprenr007 on Saturday February 20, 2016 @09:59PM (#11143087)
This article is timely for us as we're using Scala for backend work.

Ruby 2.3 &. operator and Swift can do something like this pseudocode:

    if let city = article?.author?.address?.city?.ToLower() {
       // city present
    }
Too long?:

    if let city = article?
      .author?
      .address?
      .city?
      .ToLower() {
        // city present
    }
All are improvements over pyramids of doom.

(Be aware of subtle gotcha in Scala of var and val, really prefer Rust/Go/Swift keywords.)

There are no comments on this comment yet.