DEV Community

Discussion on: What the hell is pattern matching?

Collapse
 
thatblairguy profile image
That Blair Guy • Edited

That's it? From the buzz,I expected something much more complicated.

Are there other uses?

Collapse
 
alexdhaenens profile image
Alex Dhaenens

Yeah it is quite simple, what you also can do is use this in a switch statement:

switch(person){
   case(Elf f):
   break;
}
Collapse
 
saint4eva profile image
saint4eva

person switch {
case Elf elf =>....
case Dwarf dwarf =>...

}

You can even omit the case keyword.

Collapse
 
thatblairguy profile image
That Blair Guy

Very cool. Wish I'd known about that a few weeks ago. So many features to keep track of across so many languages!

Thread Thread
 
alexdhaenens profile image
Alex Dhaenens

Yes indeed, In this blog series I’ll mainly focus on such lesser known features, stay tuned!