Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

In what way are Julia sets immutable?

$
0
0

If I create a set in Julia, then Julia will tell me that the set is immutable.

julia> pets = Set(["dog", "cat", "budgerigar"])
Set{String} with 3 elements:
  "cat"
  "budgerigar"
  "dog"

julia> ismutable(pets)
false

Nonetheless, I can modify the set in place.

julia> push!(pets, "orangutan")
Set{String} with 4 elements:
  "orangutan"
  "cat"
  "budgerigar"
  "dog"

And I can check that the set contents have changed.

julia> display(pets)
Set{String} with 4 elements:
  "orangutan"
  "cat"
  "budgerigar"
  "dog"

Similarly, I can delete from the set in place

julia> delete!(pets, "dog")
Set{String} with 3 elements:
  "orangutan"
  "cat"
  "budgerigar"

So my question is, in what way are sets immutable? In what way is their mutability different when compared with dictionaries?

julia> ismutable(Dict())
true

What am I not understanding?

6 posts - 6 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles