【发布时间】:2021-01-13 07:58:48
【问题描述】:
我正在写一个类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
【问题讨论】:
-
(字面)错误信息是否“unexpected token kEND error”?
标签: ruby syntax-error unexpected-token