What does `send()` do in Ruby, and how is it used?

send() in Ruby is used to call a method dynamically by its name as a string or symbol. Instead of calling a method directly like obj.some_method, you can use obj.send(:some_method), which is particularly useful when the method name is stored in a variable.

For example:

class Greeting
  def hello
    "Hello, world!"
  end
end

g = Greeting.new
puts g.send(:hello)  # Outputs "Hello, world!"

This is the same as calling g.hello, but send lets you choose the method dynamically.