Robert Klemme
8/14/2008 4:57:00 PM
On 14.08.2008 18:43, Patrick Li wrote:
> Hi,
> I'm having a hard time spotting my bug in this code.
> When it runs it gives me:
> uninitialized constant String::StringIO (NameError)
>
> Am I missing something? StringIO is a global constant. Why can't ruby
> find it?
>
> class String
> def self.fromURL(string)
> string = string.string if string.is_a?(StringIO)
> CGI.unescape(string)
> end
> end
$ ruby -e 'p StringIO'
-e:1: uninitialized constant StringIO (NameError)
robert@fussel ~
$ ruby -r stringio -e 'p StringIO'
StringIO
robert@fussel ~
$
Kind regards
robert