Learn Ruby
Online Store
23.1
Lesson

Required argument

In the below case the initialize method takes one argument.

If we do not provide any argument while calling new then Ruby will not like it. Ruby complaints that the initialize method is expecting an argument. It is also described as “method is throwing an exception”. We will look into excepions in a later chapter.

In the above case we did not pass any parameter to .new and the code fails.