Ruby Language Define and change constants in a class


Example

class Message
  DEFAULT_MESSAGE = "Hello, world"

  def speak(message = nil)
    if message
      puts message
    else
      puts DEFAULT_MESSAGE
    end
  end
end

The constant DEFAULT_MESSAGE can be changed with the following code:

Message::DEFAULT_MESSAGE = "Hullo, world"