Creating a StringIO object

Hi all, can any body tell me how to create a StringIO object from an
existing string object.

my code str = StringIO.new results an error saying that
“uninitialized constant StringIO(NameError)”

What i sthe problem with the above code

my code str = StringIO.new results an error saying that
“uninitialized constant StringIO(NameError)”

What i sthe problem with the above code

Posted via http://www.ruby-forum.com/.

You need to load the StringIO library:

irb(main):001:0> str = StringIO.new
NameError: uninitialized constant StringIO
from (irb):1
irb(main):002:0> require ‘stringio’
=> true
irb(main):003:0> str = StringIO.new
=> #StringIO:0xb7ce6c6c
irb(main):004:0>

HTH,

Felix

On Oct 3, 5:37 am, Venkat B. [email protected]in.invalid wrote:

Hi all, can any body tell me how to create a StringIO object from an
existing string object.

my code str = StringIO.new results an error saying that
“uninitialized constant StringIO(NameError)”

What i sthe problem with the above code

Posted viahttp://www.ruby-forum.com/.

You have to require the stringio library
require ‘stringio’

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs