Note that there are some explanatory texts on larger screens.

plurals
  1. PO+ is an undefined method after using super to call parent variables
    text
    copied!<p>This is a follow up from <a href="https://stackoverflow.com/questions/11092884/creating-a-class-which-inherits-from-another-class-in-ruby">Creating a class which inherits from another class in Ruby</a> and <a href="https://stackoverflow.com/questions/10944555/m-one-m-two-m-three-doesnt-work">m.one + m.two + m.three doesn't work</a>. We are applying for <a href="http://www.hashmaplabs.com/app_academy/code_test" rel="nofollow noreferrer">App Academy</a> which is a Learn to Code course for people with little or no experience. As a result, these questions are similar, but I felt the answers in the other two posts did not address an answer, but diverged to explaining tangential concepts (which I did utilize)</p> <p>To follow up on the first two mentioned links, I am having a problem with inherited classes. I have the Musician class which is inheriting three variables from the Person class. My problem is that when I run the </p> <pre><code>m.first_name + " " + m.last_name + ": " + m.age.to_s </code></pre> <p>I get an error: person.rb:31: undefined method `+' for nil:NilClass (NoMethodError). I understand that this error has the answer, but I am not yet adept at understanding what this means. </p> <p>One point to mention is that the query above, must be the way it is. I can not put Puts in front of it. </p> <p>I would appreciate any suggestions as to why I am getting this statement regarding + being an undefined method.</p> <p>Thanks!</p> <p>edit: Thanks for the quick response. I didnt realize the coding community was so active! This is really amazing. I am going to edit the code to reflect the newest issues, so I dont keep getting the same suggestions.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload