#1858 Str mutability?

Xan Sun 25 Mar 2012

Hi,

I'm relatively new in Fantom. I see that Lists and Maps are mutable by default, but why not Str? Why can't I do:

a := "Hola"
a[0] = 'h'

I receive Unkown method sys::Str.set

Thanks,

dobesv Sun 25 Mar 2012

Use sys::StrBuf as a mutable Str.

Xan Sun 25 Mar 2012

@dobesv: thanks. But why Str is immutable. What are the design reasons?

Thanks,

DanielFath Sun 25 Mar 2012

Well for once Str are immutable in Java, no? Also immutability is the foundation of Fantom and its Actor model.

Login or Signup to reply.