Ruby 代码中不可见的语法错误

Ruby 代码中不可见的语法错误,ruby,syntax,Ruby,Syntax,我在第23行、第28行和程序结束时不断遇到语法错误 在第23行,它说elsif语句是意外的,不属于那里 第28行表示不需要结束语句 在我的程序结束时,它说我缺少一个结束语句 我不认为我有任何语法错误,所以如果有人能帮我发现我的错误,我将不胜感激 谢谢:D def get_last_date(strt,usage_list) if usage_list.empty? return "chemical left over" end date_list=[]

我在第23行、第28行和程序结束时不断遇到语法错误 在第23行,它说elsif语句是意外的,不属于那里 第28行表示不需要结束语句 在我的程序结束时,它说我缺少一个结束语句

我不认为我有任何语法错误,所以如果有人能帮我发现我的错误,我将不胜感激 谢谢:D

def get_last_date(strt,usage_list)
    if usage_list.empty?
        return "chemical left over"
    end

    date_list=[]
    for occurrence in usage_list
        if occurrence[0] != 0
            date_list+=[occurrence[2]]
        end
    end

    currdate=datelist.min                                       # this gets the earliest start date out of all the recurring uses
    lastuse=currdate

    while true                                                  # this loop is a loop for each day and each iteration icrements the currentdate by 1
        y=0
        usinglist=[]
        for recursion in usage_list                             # gets the recurring uses that have end_dates that are after the currdate and start_dates before the currdate
            if (recursion.length==4) &(recursion[3]< currdate)  # deletes a recurring use from the list of recurring uses if its past its end_date
                usage_list.delete_at(y)
                y--
        ****line 23**** elsif recursion[2] >= currdate
                usinglist+=[recursion]
            end

            y++
    *****line 28**** end

        used=false
        if usinglist.empty?
            return "chemical left over"
        end

        for uses in usinglist
            if uses[1]==0                                       # if its a daily periodicity subtract the amount from the total
                strt=strt-uses[0]
                used=true
            elsif uses[1]==currdate.cwday                       # if the periodicity day matches the current workday then subtracts the amount for weeky periodicity cases
                strt=strt-uses[0]
                used=true
            end
        end

        if strt==0                                              # if the chemical has been used up return either currdate or last use date appropriately
            return currdate
        elsif strt<0
            return lastuse
        end

        if used                                                 # sets the last used date to the current date if you used some of the chemical today
            lastuse=currdate
        end
        currdate=currdate+1                                     # increment currdate DateTime object
    end
end
def get_last_date(strt,用法列表)
如果使用列表为空?
返回“化学残留物”
结束
日期列表=[]
用于在用法列表中出现
如果出现[0]!=0
日期列表+=[事件[2]]
结束
结束
currdate=datelist.min#这将获取所有重复使用中最早的开始日期
lastuse=当前日期
如果为true,则该循环是每天的循环,每次迭代都将当前日期乘以1
y=0
usinglist=[]
对于用法列表中的递归,获取结束日期在currdate之后、开始日期在currdate之前的重复使用
if(recursion.length==4)&(recursion[3]=currdate
usinglist+=[递归]
结束
y++
*****第28行****结束
used=false
如果使用list.empty?
返回“化学残留物”
结束
用于usinglist
如果使用[1]==0#如果是每日周期,则从总数中减去金额
strt=strt使用[0]
used=真
elsif使用[1]==currdate.cwday#如果周期日与当前工作日匹配,则减去每周周期案例的金额
strt=strt使用[0]
used=真
结束
结束
如果strt==0#如果化学品已用完,请适当返回当前日期或上次使用日期
返回日期
埃尔西夫strt
这些语句在Ruby中不存在。换成

y -= 1
y += 1
分别


另外,您似乎在第20行使用
&
而不是
&

谢谢,就是这样,这个答案很完美。
y -= 1
y += 1