Skip to content
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

Update Sets.scala #146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/scala/stdlib/Sets.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ object Sets extends FlatSpec with Matchers with org.scalaexercises.definitions.S
}

/** Set elements can be removed with a tuple:
* (note -- unary '-' on a tuple with more than one value is deprecated from scala 2.13.0)
*/
def tupleRemovingSets(res0: Boolean, res1: Boolean, res2: Int) {
val mySet = Set("Michigan", "Ohio", "Wisconsin", "Iowa")
val aNewSet = mySet - ("Michigan", "Ohio") // Notice: single '-' operator for tuples
// the above operation will work, but result in a warning:
// warning: method - in trait SetOps is deprecated (since 2.13.0): Use &- with an explicit collection argument instead of - with varargs

aNewSet.contains("Michigan") should be(res0)
aNewSet.contains("Wisconsin") should be(res1)
Expand Down