Hello --

On Mon, 21 Jan 2002, Jacek Podkanski wrote:

> Hi,
>
> I am using ruby 1.6.4 (2001-06-04) [i586-linux-gnu], and heve encountered
> following strange problems.
>
> I am writing a quite long program, more than 400 line at the moment and
> found two problems I can't solve. first will be explained by a bit of
> code...
>
>           if $root.Szukaj_Slowo(slowo) == nil   #nie znalazlem slowa
>             koncowka(slowo)
>             raise "omin"
>             printf("%s +++nieznane+++\n",slowo)
>             # lines with comments
>
>           elsif
>             #znalazlem slowo
>             print slowo,"\n"      # weird  only this line is executed


You probably mean 'else', not 'elsif'.  What's happening is like this:

   if $root.Szukaj_Slowo(slowo) == nil
      # ....
   elsif print slowo, "\n"
      # ....
   end

What that means is: slowo gets printed, and the 'elsif' tests the
return value of the call to print -- which is nil.  So the test
fails, and the laster lines don't get executed.

(By the way, you should have a look at #puts :-)

>
>             print 'going to get word classes',"\n"
>             names2List($root.Szukaj_Slowo(slowo),$lista_klas)
>             #print $lista_klas.inspect,"\n"
>           end
>
> in elseif section only first line is executed namely  print slowo,"\n"
> I wonder if anyone know what's wrong
>
> The second problem was with my own exception objects. I had following class
>
> class MyException < RuntimeError
>   def initialize(exception) ...
>     ...
>   end
> end
> and when I was trying to do
>
> raise MyException.new('some exception string')
>
> I was getting exception object expected error.
>
> The same worked fine with one of my small scripts. but in this biggish
> program it didn't

I'm not sure with that one.  Maybe you're defining class MyException
inside another class or module definition, then calling it from
somewhere else?


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav