Define and change constants in a class
suggest changeclass 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"
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents