0
0
Rubyprogramming~15 mins

String concatenation and << in Ruby - Mini Project: Build & Apply

Choose your learning style9 modes available
String concatenation and << in Ruby
📖 Scenario: You are creating a simple greeting message by joining different parts of text.
🎯 Goal: Build a greeting message by concatenating strings using the + operator and the operator.
📋 What You'll Learn
Create a string variable with a greeting
Create a string variable with a name
Concatenate the greeting and name using +
Add an exclamation mark using <<
Print the final greeting message
💡 Why This Matters
🌍 Real World
Building messages dynamically is common in apps like chat programs, notifications, and user interfaces.
💼 Career
Understanding string manipulation is essential for software development, especially when preparing text output or user messages.
Progress0 / 4 steps
1
Create greeting and name strings
Create a string variable called greeting with the value "Hello" and another string variable called name with the value "Alice".
Ruby
Need a hint?

Use = to assign strings to variables.

2
Concatenate greeting and name with +
Create a new string variable called message by concatenating greeting, a space " ", and name using the + operator.
Ruby
Need a hint?

Use + to join strings and include a space between words.

3
Add exclamation mark using <<
Use the << operator to add an exclamation mark "!" to the end of the message string.
Ruby
Need a hint?

The << operator adds text to the existing string.

4
Print the final message
Print the message variable to display the full greeting.
Ruby
Need a hint?

Use puts to print the string to the screen.