我试图创建二维数组但是我收到了错误。这是我的代码:
def create
@comment = current_user.comments.create(comment_params)
if @comment.save
flash[:success] = 'Your comment was added!'
redirect_to Story.friendly.find params[:story_id]
else
# what to put here to show my comment form with errors
end
end
我收到此错误:
TypeError:错误#1010:术语未定义且没有属性。
在SubtitleLoader / onComplete()[C:\ Users \ ... \ SubtitleLoader.as:88]
at flash.events :::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
第88行:cleanArr [i] [0] = arr [i] .substring(0,29);
我该如何解决这个问题?
答案 0 :(得分:2)
cleanArr完全为空,它不是2D数组。要使它成为2D数组,其中的项必须是数组。在您的代码中,它们根本不存在。您必须首先在给定位置创建一个数组。试试这个:
var cleanArr:Array = new Array();
for (var i:int = 0; i < arr.length; i++)
{
cleanArr[i] = new Array();
cleanArr[i][0] = arr[i].substring(0, 29);
cleanArr[i][1] = arr[i].substring(29, int.MAX_VALUE);
trace(cleanArr[i]);
}