Out of interest why does this work in Scala:
val exceptions = List[Char]('+')
assertTrue(exceptions.contains('+'))
but this not
val exceptions = new Array[Char]('+')
assertTrue(exceptions.contains('+'))
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.
Because you wrote new ArrayChar. Doing that, the argument is the size of the array, and the ‘+’ is, rather unfortunately, converted to an int to give the size. And the returned array is full of Char(0).
You should just do
Array[Char]('+'),'+'would then be single element in the Array.