I have an array of strings. What’s the best way to turn it into an immutable set of strings?
I presume this is a single method call, but I can’t find it in the scala docs.
I’m using scala 2.8.1.
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.
This method called
toSet, e.g.:In this case
toSetmethod does not exist for theArray. But there is an implicit conversion to ArrayOps.In such cases I can advise you to look in Predef. Normally you should find some suitable implicit conversion there.
genericArrayOpswould be used in this case.genericWrapArrayalso can be used, but it has lower priority.