Default Arguments : Method Arguments « Method « Ruby
- Ruby
- Method
- Method Arguments
Default Arguments
def repeat( word="Hello! ", times=3 )
puts word * times
end
repeat # => Hello! Hello! Hello!
repeat( "Goodbye! ", 5 ) # => Goodbye! Goodbye! Goodbye! Goodbye! Goodbye!
Related examples in the same category