From: Stefano Crocco Date: 2009-11-24T19:05:39+09:00 Subject: Re: Warning: instance variable @foo not initialized On Tuesday 24 November 2009, Seebs wrote: > |On 2009-11-24, Stefano Crocco wrote: > |> To answer your question: the library should have set those variable to > |> nil before using them, if it wanted to avoid the warning (not > |> necessarily in initialize, just before the variables were used). Not > |> doing so, however, is perfectly correct, if you don't mind seeing the > |> warnings. Personally, I don't like them, so I always assign instance > |> variables before using them. > | > |Thanks! > | > |> I hope this helps > | > |It does. I guess I'm a bit confused, 'cuz on the one hand, Prawn looks > |pretty nice, but on the other hand, getting thousands of lines of warnings > |running a simple test program sorta worries me. > | > |-s > | As I said, there's nothing wrong with not initializing instance variables to nil: it's a matter of preferences. It seems Prawn's author doesn't like to initialize variables to nil (indeed, it looks a bit too C-like for ruby) and doesn't mind some warnings. If the warnings only annoy you, you should be able to disable them by not passing the -w option to ruby. If instead you're worried that they can mean there's something wrong, I think you don't need to. Most of the times, warnings issued by ruby are harmless. Stefano