#2308 Str / StrBuf / Int [] conversions

tomcl Fri 4 Jul 2014

I may be missing something as a newbie, so I'm hoping someone can help:

StrBuf seems very similar to Int []. What are the semantic differences? Other than a different set of methods of course...

I'm finding it awkward to get from Str to StrBuf. To turn an immutable into a mutable string. There is no toStrBuf method on Str nor any way round I can see?

EDIT: on reflection I'm not sure I have a good use case for this. StrBuf can usually be replaced by Str - it just seems a gap in the API.

Tom

brian Fri 4 Jul 2014

StrBuf seems very similar to Int [].

Its not really designed to act like a Int[], rather its a mutable char[] array. If you really want a super efficient list of bytes, or other sized ints you can use sys::Buf or util::IntArray.

I'm finding it awkward to get from Str to StrBuf.

It would be StrBuf().add(str)

tomcl Fri 4 Jul 2014

Stupid of me! Thanks!

SlimerDude Wed 9 Jul 2014

I'm often wanted the ctor, or rather, I've often typed StrBuf(str) - for it is a natural construct that you would expect. How about it?

If so, then what may be nice (but I'm not too concerned about) is, as Tom says, a matching Str.toStrBuf() method for convenience, similar to Str.toBuf()

Login or Signup to reply.