Last active
May 14, 2017 05:15
-
-
Save dgadiraju/336dd9ffb231ca2ffe1aa5df7c28c81f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//os is of type immutable set, | |
//hence elements cannot be added to set | |
//+=, ++=, -=, --= will not work | |
val os = Set( | |
Order(1, "2017-01-01", 100, "COMPLETE"), | |
Order(2, "2017-01-01", 20, "CLOSED") | |
) | |
//Creating new set by adding element | |
os + Order(3, "2017-01-01", 301, "PENDING") | |
//We can add elements using +=, ++=, -=, --= | |
val os = collection.mutable.Set( | |
Order(1, "2017-01-01", 100, "COMPLETE"), | |
Order(2, "2017-01-01", 20, "CLOSED") | |
) | |
//+=, ++=, -=, --= will work to manipulate mutable sets | |
os += Order(3, "2017-01-01", 301, "PENDING") | |
//But below statement will not work | |
// as we are trying to assign to immutable os | |
os = os + Order(4, "2017-01-01", 301, "PENDING") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment