-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sameElements compares the elements, not just the number of elements #18
Comments
Thank you @davidallsopp , I didn't know about this bug. You are reporting several issues. I would like that your contributions gain recognition. Why don't you submit a new "pull request" with your fix for this particular issue?
Thanks a lot, dude! |
rafaparadela
pushed a commit
that referenced
this issue
Mar 11, 2015
More precise explanation of sameElements, addressing issue #18
Fixed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://scala-exercises.47deg.com/koans#iterables says that "sameElements will return true if the two iterables have the same number of elements"
That's a necessary, but not sufficient condition. The elements have to be the same, too. Whether the ordering matters depends on the collection:
scala> List(1,2,3) sameElements List(1,2,3)
res13: Boolean = true
scala> List(1,2,3) sameElements List(3,2,1)
res14: Boolean = false
scala> Set(1,2,3) sameElements Set(3,2,1)
res15: Boolean = false // WHAT?
scala> Set(1,2,3,4,5,6) sameElements Set(6,5,4,3,2,1)
res16: Boolean = true
Also, sameElements for Set produces unexpected results - the behaviour changes depending on the size of the Set, as you can see above! This is arguably a bug in the Scala library: https://groups.google.com/forum/#!topic/scala-debate/je4vZbR3WbA
The text was updated successfully, but these errors were encountered: