가장 많이 묻는 면접 질문과 답변 & 온라인 테스트
면접 준비, 온라인 테스트, 튜토리얼, 라이브 연습을 위한 학습 플랫폼

집중 학습 경로, 모의고사, 면접 준비 콘텐츠로 실력을 키우세요.

WithoutBook은 주제별 면접 질문, 온라인 연습 테스트, 튜토리얼, 비교 가이드를 하나의 반응형 학습 공간으로 제공합니다.

Prepare Interview

Ruby On Rails 면접 질문과 답변

Question: What is the purpose of YIELD in Ruby on Rails?
Answer:

The interpreter essentially invokes a separate piece of code and places it in the location. You might say it is similar to a method calling another method. Lets understand a little bit of background about where YIELD might be useful first. 

The Rails framework encourages you to write code that is DRY (Dont Repeat Yourself).

Developers often write common code in a central file and then they write the custom code in the specific files. Lets say you are building a web application and you want all pages to have a common header, a common footer, the same Welcome user-name! message.

You can put all this common code in your application.html.erb file.

<html> .... common page title
.. standard header... 
<body> 
..common page title,
 <%= YIELD %>
..footer code can go here... </body> 
</html>

The rest of the custom code can go in your specific file. Say the page you are creating is the list of articles. Then in your implementation file you would just write the code for pulling in the articles and the final page displayed to the user would be your custom code which will be placed instead of the <%= YIELD %>code in the application.html.erb file.

복습용 저장

이 항목을 북마크하거나, 어렵게 표시하거나, 복습 세트에 넣을 수 있습니다.

내 학습 라이브러리 열기
도움이 되었나요? 아니요

Most helpful rated by users:

Copyright © 2026, WithoutBook.