Skip to main content

Pattern Matching

  • Chapter
  • First Online:
Scala for Java Developers
  • 1658 Accesses

Abstract

As well as providing switch-like functionality (that's more powerful than Java's version), pattern matching offers a rich set of "patterns" that can be used to match against. In this chapter, we'll look at the anatomy of patterns and talk through some examples, including literal, constructor, and type query patterns.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 24.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    http://www.scala-lang.org/files/archive/spec/2.12/08-pattern-matching.html

  2. 2.

    http://www.scala-lang.org/files/archive/spec/2.12/08-pattern-matching.html

  3. 3.

    http://www.artima.com/pins1ed/extractors.html

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Toby Weston

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Weston, T. (2018). Pattern Matching. In: Scala for Java Developers. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3108-1_16

Download citation

Publish with us

Policies and ethics