为什么这不是一个有效的操作?Ruby未定义方法'+'为零:NilClass
def get_highest_bar()
#convert string to integer array
data = @data.split(",")
return Integer(data.max)
end
#rounds up to nearest factor of 100
def round_up(n)
return 100 if n < 100
return (n+50)/100*100
end
@axis_range_prefix = "chxr="
@y_axis_index = "1"
#error here:
axis_range = @axis_range_prefix + [@y_axis_index, "0", highest_bar.to_s()].join(",")
谢谢! Java倾向很难消退。 .map(&:to_i)'部分是否将列表中的每个值都传递给to_i()函数? '&'和':'是什么意思?对不起,我是Ruby新手。 –
它是'.map {| x |的简写x.to_i}' –
当我尝试执行'@ data.split(“,”).map(&:to_i).max'时,我收到一个错误:'错误的参数类型符号(期望的Proc)' –