Skip to content

Instantly share code, notes, and snippets.

@husen-hn
Created August 7, 2020 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save husen-hn/73af94e31a395331953f4be95000e7af to your computer and use it in GitHub Desktop.
Save husen-hn/73af94e31a395331953f4be95000e7af to your computer and use it in GitHub Desktop.
val mutable = MyValue.Mutable("Foo")
val immutable = MyValue.Immutable("Foo")
mutable.value = "Bar" // This is fine
immutable.value = "Bar" // This will not compile because value cannot be reassigned
val mutated = immutable.mutate()
mutated.value = "Bar" // This is fine
immutable.value = "Bar" // This will not compile because value cannot be reassigned
val immutated = mutated.immutate()
immutated.value = "Bar" // This will not compile because value cannot be reassigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment