# What's the intended behavior of this program that uses a Set as the Sequence it currently is?

**URL:** <https://forums.swift.org/t/whats-the-intended-behavior-of-this-program-that-uses-a-set-as-the-sequence-it-currently-is/11753>\
**Category:** Using Swift\
**Created:** [April 7, 2018, 3:04pm UTC](https://forums.swift.org/t/whats-the-intended-behavior-of-this-program-that-uses-a-set-as-the-sequence-it-currently-is/11753 "2018-04-07T15:04:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ben-cohen](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ben-cohen/32/296_2.png) [@ben-cohen](https://forums.swift.org/u/ben-cohen)\
**Post date:** [April 7, 2018, 3:30pm UTC](https://forums.swift.org/t/whats-the-intended-behavior-of-this-program-that-uses-a-set-as-the-sequence-it-currently-is/11753/2 "2018-04-07T15:30:12Z")

</div>

This is because hash values of `String` on master now include different random salt on each execution of your program (see @lorentey's [recent post](https://forums.swift.org/t/psa-the-stdlib-now-uses-randomly-seeded-hash-values/10789)) . Since the order of elements in the `Set` is affected by those hash values, you will get different results between runs.

Given you should never be relying on the set having a particular order full stop, it doesn't matter that that order can vary between runs.

The only thing you can rely on with a `Set` is that multiple passes over a `Set` will return the values in the same order on each pass (assuming no mutation is happening in-between).

---

_[View the full topic](https://forums.swift.org/t/whats-the-intended-behavior-of-this-program-that-uses-a-set-as-the-sequence-it-currently-is/11753)._
