编写 Ruby 类方法并获得意外的令牌 kEND 错误

问题描述

我正在编写一个类 Wrapper,并给它一个类方法 self.wrap。我收到 unexpected end-of-input 错误。我一直盯着代码看,看不出哪里出错了。我想我已经准备好了所有的 end。我错过了什么?

require 'pry'
class Wrapper
    def self.wrap(input_string,column_number)
        position = 0
        num_inserted = 0
        while (position + column_number < line.length) do
            last_space_index = input_string.rindex(" ",position + column_number)
            if last_space_index > position - 1
                input_string[num_inserted + last_space_index] = "\n"
            else
                input_string.insert(num_inserted + position + column_number,"\n")
                position += column_number
                num_inserted ++
            end
        end
    end
end

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)