紅寶石,通常是非常寬容的,給我一個while循環的錯誤;我看不出爲什麼。紅寶石雖然錯誤
def foo(vals)
n = vals.length
key = n-1
newkey = n-1
while ((key > 0) && (vals[key] <= vals[key-1])) key--
key
end
錯誤:
prog.rb:37: syntax error, unexpected tIDENTIFIER, expecting keyword_do_cond or ';' or '\n'
while ((key > 0) && (vals[key] <= vals[key-1])) key--
^
任何想法?
哪裏使用了newkey? – tokland 2012-01-09 23:12:45
可能重複[ruby遞增整數](http://stackoverflow.com/questions/7993915/ruby-incrementing-integer) – 2012-01-10 00:41:08