Skip to main content
  • 118k Accesses

Abstract

This chapter introduces another type of class in Scala, Value Classes. A Value Class is a type where the actual value being represented by the type class is hold directly by a variable, rather than needing to access that value via a reference (an address in memory). Examples of Value Types include Booelan, Int and Double which can have the values true, false, 32, 45.7, etc. Such values can be held directly by a variable, rather than accessed via a reference. This can be more efficient for simple types like Int.

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

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 69.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

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to John Hunt .

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer International Publishing AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Hunt, J. (2018). Value Classes. In: A Beginner's Guide to Scala, Object Orientation and Functional Programming. Springer, Cham. https://doi.org/10.1007/978-3-319-75771-1_15

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-75771-1_15

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-75770-4

  • Online ISBN: 978-3-319-75771-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics