exercises-stdlib icon indicating copy to clipboard operation
exercises-stdlib copied to clipboard

Fix Sets "tuple" example because it's misleading

Open EdgeCaseBerg opened this issue 7 years ago • 3 comments

This example is incorrect. The statement

Set(1,2,3) - (1,2)

(for example) does not use a tuple at all, it's the same thing as this:

Set(1,2,3).-(1,2)

Which is calling the overloaded version of the - method of Set which accepts two initial arguments plus a varadiac list of however many elements you want which allows you to do things like

Set(1,2,3,4) - (1,2,3,4,5) // etc

No where in this are tuples ever actually used. And to say so (as it does currently) is misleading to programmers trying to use scala-exercises as a way of learning the standard library. If you DID try to use a tuple it would not work:

Set(1,2,3) - ((1,2)) //this will not compile

because the types to not align.

EdgeCaseBerg avatar Nov 08 '17 21:11 EdgeCaseBerg

@EdgeCaseBerg thanks for the clarifications. Can we keep the number of args in the exercise the same as before so already answered exercises remain correct for users that have already completed them? thanks!

raulraja avatar Dec 10 '17 21:12 raulraja

Hey @raulraja Sorry for the late response, I can change the number of arguments in the exercise to be the same. I think I'll have to remove the example around val anotherNewSet = mySet - ("Michigan", "Ohio", "Iowa") // You can pass as 2 or more arguments, this method is varadiac! and just note that the method is varadiac and what that means in the comment for the pre-existing test.

EdgeCaseBerg avatar Dec 13 '17 14:12 EdgeCaseBerg

@raulraja I'm added 8cc7523 to address your comment.

EdgeCaseBerg avatar Dec 13 '17 14:12 EdgeCaseBerg