Pattern Matching using switch in Reason

InstructorNik Graf

Share this video with your friends

Send Tweet

Pattern matching is probably one of the best features of the language. It comes down to two points:

  • check for a certain structure of a value
  • extract parts of that value

Since it's such an integral part of the language it comes with a lot of useful tricks like piping multiple patterns into one case. In this lesson we will explore all of them.

Artem Korchunov
Artem Korchunov
~ 6 years ago

Hi Nik, you have missed ed ending for Not request there

Reason #
type request = 
  | Loading 
  | Success(string)
  | Error(int);
  | NotRequest;
type request = Loading | Success(string) | Error(int) | NotRequested;
Nik Graf
Nik Graf(instructor)
~ 6 years ago

Good catch, thx Artem. Will notify the Egghead team to fix it.