Bird
0
0

Which of the following is the correct syntax to create a single-quoted string with a single quote inside it?

easy📝 Syntax Q3 of 15
Ruby - Variables and Data Types
Which of the following is the correct syntax to create a single-quoted string with a single quote inside it?
A'"It\'s sunny"'
B'It\'s sunny'
C'It's sunny'
D"It's sunny"
Step-by-Step Solution
Solution:
  1. Step 1: Understand escaping single quotes inside single-quoted strings

    Inside single quotes, a single quote must be escaped with \' to avoid ending the string early.
  2. Step 2: Identify correct escaping

    The string 'It\'s sunny' correctly escapes the single quote inside single quotes.
  3. Final Answer:

    'It\'s sunny' -> Option B
  4. Quick Check:

    Escape single quote inside single quotes = \' [OK]
Quick Trick: Escape single quote inside single quotes with \' [OK]
Common Mistakes:
MISTAKES
  • Not escaping single quote inside single quotes
  • Using wrong quote marks
  • Confusing escape sequences

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes