From: adamon@... (Damon) Date: 2002-08-04T14:16:57+09:00 Subject: Re: JRuby changes breaking code? Thanks! Much obliged. Damon Anders Bengtsson wrote in message news:<1028373734.1727.17.camel@spinoza>... > A few minutes later: It turned out it wasn't a bug in JRuby at all. But > the exception isn't as clear as it can be. > > > > Exception in thread "main" java.lang.ClassCastException: > > > org.jruby.RubyRange > > > at org.jruby.javasupport.JavaUtil.convertRubyToJava(JavaUtil.java:163) > > > at org.jruby.Ruby.evalScript(Ruby.java:203) > > > at Java2Ruby.main(Java2Ruby.java:33) > > This instead is where the error is: > > > > String rubySource = "listContents = []\n" + > > > "(1..9).each { |x| listContents << " + > > > "(\"cat number \" + x.to_s)}\n"; > > The each() will here return (1..9), which causes the classcast exception > for RubyRange. > I guess the intended code has an extra row at the end, like this: > > String rubySource = "listContents = []\n" + > "(1..9).each { |x| listContents << " + > "(\"cat number \" + x.to_s)}\n" + > "listContents\n"; > > /Anders