Method naming conventions (? and ! suffixes)
📖 Scenario: You are building a simple Ruby program to check and modify strings. In Ruby, methods that end with ? usually return true or false, and methods that end with ! usually change the object itself.
🎯 Goal: You will create methods with ? and ! suffixes to practice Ruby naming conventions. You will write a method to check if a string contains vowels and another method to remove vowels from the string permanently.
📋 What You'll Learn
Create a method called
contains_vowels? that returns true if the string has any vowels.Create a method called
remove_vowels! that removes vowels from the string permanently.Use the
? suffix for the method that returns a boolean.Use the
! suffix for the method that modifies the string.Print the results to show the methods work as expected.
💡 Why This Matters
🌍 Real World
These naming conventions help programmers quickly understand if a method will just check something or if it will change data. This is useful when working on bigger Ruby projects or with other developers.
💼 Career
Knowing Ruby method naming conventions is important for writing clear, maintainable code. Many Ruby jobs expect you to follow these conventions to avoid bugs and improve teamwork.
Progress0 / 4 steps