Can I use primitives in Scala?
The use case is for storing billions of ints, so the difference between 4 bytes (for an int) and 16 bytes (for an Integer) is important.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want Scala to store unboxed primitives, you could use
Array[Int]but refrain from using any cool Scala collection method on it (because it will force boxing).If you look for immutable collections of primitives types, you can have a look at Debox, which provides specialised Buffers, Sets and Maps. The project is still evolving but it is very promising.