Search⌘ K
AI Features

Exercise 1: Greet a Person

Explore how to write a Ruby method named greet that takes a name as input, adds a friendly greeting around it, and prints the final string. This lesson helps you understand method creation, parameter usage, and output in Ruby's syntax, building foundational programming skills.

We'll cover the following...

Problem statement

Write a greet method that takes a name, prepends "Hello ", appends an exclamation mark, "!", and then prints the resultant string.

Example

greet("Ada")

This prints:

Hello Ada!

Try it yourself

Ruby
# Start your code here