Nasa countdown in JRuby

9 views
Skip to first unread message

ngsmrk

unread,
Jun 5, 2011, 5:48:48 PM6/5/11
to coding kata
I have been working my way through the katas and have got a solution
for the NASA countdown one but when I run it I get the following
error:
[INFO] Compilation failure
/projects/codekata/nasa-countdown-solv-jruby/target/jrubyc-generated-
sources/org/codingkata/unit/MyKata.java:[85,16] illegal start of
expression

I have run the exact same code through irb and it works fine - does
anybody have any suggestions?

Cheers,

N

See the solution below

CODE FOLLOWS

----------

require 'java'
java_package 'org.codingkata.unit'
java_import 'org.codingkata.unit.api.IKataSolution'

class MyKata
java_implements IKataSolution

java_signature 'public Integer[] countdown(int start)'
def countdown(start)

output = Array.new

#count up using range to set array elements
(0...start).each do | i |
output << i
end

# reverse the array
return output.reverse.to_java :int

end

end
Reply all
Reply to author
Forward
0 new messages