I'm not sure if this is a bug or a feature mimicking one-way IO, but I got a bit confused with this functionality:
Initializing an empty StringIO instance with no constructor parameters allows me to read-from and write-to it:
a = StringIO.new
a << 'test'
a << 'test'
a.string # => "testtest"
But then when I use the constructor to initialise an initial value it becomes read-only:
b = StringIO.new 'test'
b << 'test'
b.string # => "test"
I would assume this should also result in "testtest" but I might be wrong. It looks like when I create a StringIO instance and initialise it using the constructor it becomes read-only. Is this intentional?
Also I couldn't find any documentation on the << operator in regards to StringIO so maybe I shouldn't be using it?
Sorry about the inconvenience
Extra info:
$ gem list | grep stringio
stringio (default: 0.1.0)
Hello,
I'm not sure if this is a bug or a feature mimicking one-way IO, but I got a bit confused with this functionality:
Initializing an empty StringIO instance with no constructor parameters allows me to read-from and write-to it:
But then when I use the constructor to initialise an initial value it becomes read-only:
I would assume this should also result in
"testtest"
but I might be wrong. It looks like when I create a StringIO instance and initialise it using the constructor it becomes read-only. Is this intentional?Also I couldn't find any documentation on the
<<
operator in regards to StringIO so maybe I shouldn't be using it?Sorry about the inconvenience
Extra info: