The following code is from the book Exceptional Ruby:
starts_with_a = Object.new
def starts_with_a. ===(e)
/^A/ =~ e.name
end
If I comment out the first line where a new object is assigned to starts_with_a
, then I get this error:
`<main>': undefined local variable or method `starts_with_a' for main:Object (NameError)
Question 1: why do I need to assign a new object to starts_with_a
to avoid that error?
Also, the method definition starts_with_a
has a .
before the ===
, although the variable starts_with_a
does not. There's an error if I leave out that .
in the method definition.
Question 2: what is happening with that .
? why is it necessary etc.