Ruby is a popular programming language. What is its main use?
Think about what Ruby is famous for in software development.
Ruby is mainly used for building web applications and scripting tasks. It is not used for hardware design, OS creation, or media editing.
Look at the Ruby code below. What will it print?
puts 'Hello, Ruby!'
Remember Ruby is case-sensitive and 'puts' prints exactly what is inside the quotes.
The code prints the string exactly as it appears, including capitalization.
Consider this Ruby code. What will it output?
def greet(name = 'friend') "Hello, #{name}!" end puts greet puts greet('Alice')
Look at the default parameter in the method definition.
The method greet has a default argument 'friend'. Calling greet without arguments uses the default. Calling with 'Alice' uses that value.
Look at this Ruby code snippet. What error will it cause?
arr = [1, 2, 3] puts arr[5]
What happens when you access an array index that does not exist in Ruby?
Ruby returns nil when accessing an array index outside its range, no error is raised.
Ruby has many features. Which one below is a unique characteristic of Ruby?
Think about how Ruby treats data and code elements.
In Ruby, everything is an object, including numbers, classes, and even nil. This is different from many languages where primitives are not objects.