开发者

Strange error: Inflate GZip String in Ruby

开发者 https://www.devze.com 2023-04-05 00:37 出处:网络
The line test = Zlib::Inflate.inflate(inputstring) Gives me NameError: uninitialized constant Tk::Butto开发者_Go百科n::Inflate

The line

test = Zlib::Inflate.inflate(inputstring)

Gives me NameError: uninitialized constant Tk::Butto开发者_Go百科n::Inflate

I'm using Tk for the interface, but if I uncomment this line everything works fine (test isn't used elsewhere)

(Source for code below http://corelib.rubyonrails.org/classes/Zlib/Inflate.html )

def inflate(string)
zstream = Zlib::Inflate.new
buf = zstream.inflate(string)
zstream.finish
zstream.close
buf
end

newString = inflate(inputstring)

also gives me also a similar/same NameError

P.S. Edits are strange... (had to make more changes)


Did you require 'zlib' at the beginning of your file?

Ruby is looking for the Inflate constant in the Tk::Button namespace, you can force it to look at the root with:

test = ::Zlib::Inflate.inflate(inputstring)
0

精彩评论

暂无评论...
验证码 换一张
取 消