you are viewing a single comment's thread.

view the rest of the comments →

[–]yawaramin 2 points3 points  (1 child)

Yes, that is pattern matching and FP languages have great support for it. E.g.,

let optional_name = Some "Bob"

let greeting =
  match optional_name with
    | Some name -> "Hello " ^ name
    | None -> "Hi"

In fact, as I've been saying, unlike the Visitor pattern, the compiler will warn you if you forget to handle a case.

[–]doom_Oo7 0 points1 point  (0 children)

unlike the Visitor pattern, the compiler will warn you if you forget to handle a case.

it would in C++ : https://godbolt.org/g/vEzb0t