Hi!
I have a function that uses `IOBuffer` for this creating one `String` like 
the example. 
Is it needed or recommended `close` the IOBuffer after `takebuf_string`?
Best!

On Tuesday, February 17, 2015 at 1:47:08 PM UTC-3, Stefan Karpinski wrote:
>
> IOBuffer is what you're looking for:
>
> buf = IOBuffer()
> for i = 1:100
>    println(buf, i)
> end
> takebuf_string(buf) # => returns everything that's been written to buf.
>
> The takebuf_string function really needs a new name.
>
> On Tue, Feb 17, 2015 at 9:06 AM, Maurice Diamantini <
> maurice.d...@gmail.com <javascript:>> wrote:
>
>> Hi,
>>
>> In Ruby, String is mutable which allows to build large strings like this:
>>     txt = ""
>>     for ...
>>         txt << "yet another line\n"
>>     end
>>     # do something with txt
>>
>> The Julia the (bad) way I use is to do:
>>     txt = ""
>>     for ...
>>         txt *=  "yet another line\n"
>>     end
>>     # do something with txt
>>
>> Which is very slow for a big string (because it build a new more and more 
>> string at each iteration).
>>
>> So is there another way to do it (in standard Julia)?
>> Or is there another type which could be used (something like a Buffer 
>> type or Array type)?
>>
>> Thank,
>> -- Maurice
>>
>
>

Reply via email to