Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a single-line comment in Ruby.
Ruby
[1] This is a comment Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using // or -- which are comment symbols in other languages.
Forgetting to add any symbol before the comment text.
✗ Incorrect
In Ruby, single-line comments start with the # symbol.
2fill in blank
mediumComplete the code to add a multi-line comment using =begin and =end in Ruby.
Ruby
=begin
[1]
This is a multi-line comment.
=end Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the text empty between =begin and =end.
Using code instead of comment text inside the block.
✗ Incorrect
Text between =begin and =end is treated as a multi-line comment in Ruby.
3fill in blank
hardFix the error in the comment syntax below.
Ruby
[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using comment symbols from other languages like // or /* */.
Trying to use multi-line comment syntax for a single line.
✗ Incorrect
Ruby uses # for single-line comments, not //.
4fill in blank
hardFill both blanks to create a method with a comment describing its purpose.
Ruby
# [1] def greet(name) puts "Hello, #{name}!" end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing comments unrelated to the method's purpose.
Leaving the comment blank.
✗ Incorrect
The comment describes that the method greets a person.
5fill in blank
hardFill all three blanks to add a multi-line comment explaining the code.
Ruby
=begin [1] [2] [3] =end def add(a, b) a + b end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing incorrect descriptions about the method.
Using single-line comment syntax inside multi-line comment block.
✗ Incorrect
The multi-line comment explains the method's purpose, inputs, and output clearly.