Concept Flow - String creation (single and double quotes)
Start
Choose quote type
'single'
Create string
Output string
End
The program starts by choosing either single or double quotes to create a string, then outputs the string.
str1 = 'Hello' str2 = "World" puts str1 puts str2
| Step | Action | Evaluation | Result |
|---|---|---|---|
| 1 | Assign str1 = 'Hello' | str1 = 'Hello' | str1 holds string Hello |
| 2 | Assign str2 = "World" | str2 = "World" | str2 holds string World |
| 3 | puts str1 | Output str1 | Hello |
| 4 | puts str2 | Output str2 | World |
| 5 | End of program | No more instructions | Program stops |
| Variable | Start | After 1 | After 2 | Final |
|---|---|---|---|---|
| str1 | nil | 'Hello' | 'Hello' | 'Hello' |
| str2 | nil | nil | 'World' | 'World' |
Ruby strings can be created with single ('') or double ("") quotes.
Single quotes create simple strings without special character processing.
Double quotes allow special characters (like \n) and string interpolation.
Use backslash to escape quotes inside strings.
Use puts to print strings to the console.