Ruby 란 무엇입니까?Ruby에서 if/elsif/else와 함께 조건의 오류 유무 사용하기
if executing the next line wouldn't cause any kind of error then
execute this line
elsif executing the next line wouldn't cause any kind of error then
execute this line
else
구조 및 예외와 평가를 위해 API 페이지를 읽었으나 지금까지 내 퀘스트에서 실패했습니다.
많은 감사,
스티븐. 다음과 같이
if first_condition
execute_this_line rescue nil
elsif second_condition
execute_that_line rescue nil
end
는 결과가됩니다
아사 프 아킨에서 comment에 이어, 나는 다음과 같은 구문을 제안하는거야? first_condition 사실이며이 오류없이 execute_this_line 가능 있다면
, 그것은 execute_this_line됩니다.
first_condition이 true이고 execute_this_line이 일반적으로 을 생성하면 오류로 끝납니다.
첫 번째 조건이 거짓 인 경우 second_condition을 테스트합니다.
오류없이 second_condition이 true이고 execute_that_line이 가능하면오류가 발생하면 execute_that_line 오류가 발생합니다.
그렇지 않으면 끝으로 이동합니다.
if lineA doesn't cause an error execute lineA elsif lineB doesn't cause an error execute lineB end
당신이 그것을 원하는 방법으로이 권리인가 :
루비가 미래를 예측하는 방법을 실제로 묻는 중입니까? – Chuck