Bird
0
0

Which of the following is the correct way to write a multi-line comment in Ruby?

easy📝 Syntax Q12 of 15
Ruby - Basics and Runtime
Which of the following is the correct way to write a multi-line comment in Ruby?
A// This is a multi-line comment //
B/* This is a multi-line comment */
C<!-- This is a multi-line comment -->
D=begin This is a multi-line comment =end
Step-by-Step Solution
Solution:
  1. Step 1: Recall Ruby multi-line comment syntax

    Ruby uses =begin and =end to mark multi-line comments.
  2. Step 2: Check other options

    Options B, C, and D are multi-line comment styles from other languages (C, HTML, JavaScript).
  3. Final Answer:

    =begin This is a multi-line comment =end -> Option D
  4. Quick Check:

    Multi-line comment = =begin ... =end [OK]
Quick Trick: Use =begin and =end for multi-line comments in Ruby [OK]
Common Mistakes:
  • Using /* */ which is not valid in Ruby
  • Using HTML style comments
  • Trying to use // for multi-line comments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes