Learn Ruby
Required and default arguments
23.1
Lesson
Required argument in initialize
In the below case the initialize
method takes one argument.
While calling the new
method we can pass the value hot
.
We can also tell Ruby that if no value is passed then take “hot” as the default value.
Now when we are not passing any value then “hot” is the default value. If we pass a value then that value would take override the defautl value.