RubyHow do you define a simple class and method in Ruby?
class Greeter
def greet(name)
"Hello, #{name}!"
end
end
greeter = Greeter.new
puts greeter.greet("Alice") # Output: Hello, Alice!
class Greeter
def greet(name)
"Hello, #{name}!"
end
end
greeter = Greeter.new
puts greeter.greet("Alice") # Output: Hello, Alice!