ruby-метод: оператор if внутри оператора if

Я получаю много ошибок в моей программе из-за отсутствия / наличия слишком большого количества маркеров конца в моей программе. Я тестировал этот фрагмент кода раньше, и он работает, но мне просто интересно, может ли кто-нибудь сказать мне, достаточно ли у меня "конца" в этом операторе if или слишком много. Спасибо

def hop! (D)

if d== 0  
    if @current_location.addpoint(0,1) < @boundary1 
    puts "error"
    elsif if @current_location.addpoint(0,1) > @boundary2
    puts "error2"
    else
    @current_location= @current_location.addpoint(0,1) 
    puts "all good"
    end
    end
elsif d == 1
if @current_location.addpoint(0,-1) < @boundary1 
    puts "error"
    elsif if @current_location.addpoint(0,-1) > @boundary2
    puts "error2"
    else
    @current_location= @current_location.addpoint(0,-1) 
    puts "all good"
    end
    end
elsif d== 2
if @current_location.addpoint(1,0) <  @boundary1 
    puts "error"
    elsif if @current_location.addpoint(1,0) >  @boundary2
    puts "error2"
    else
    @current_location= @current_location.addpoint(1,0) 
    puts "all good"
    end
    end

else d= 3
if @current_location.addpoint(-1,0) <  @boundary1 
    puts "error"
    elsif if @current_location.addpoint(-1,0) >  @boundary2
    puts "error2"
    else
    @current_location= @current_location.addpoint(-1,0) 
    puts "all good"
    end
    end

end
0
задан Josh Lee 5 October 2011 в 22:47
поделиться