In the following code example, why does the second (sheetplus) method seem to pick up the instance variables @name and @occupation fine, but the first (sheet) method return nil? I feel like I’m missing something deadly obvious, but I am basically the world’s worst Ruby programmer.
class Test
def initialize(name, occupation)
@name = name
@occupation = occupation
def sheet
"This is #@name, who is a/an #@occupation"
def sheetplus
"This is #@name, who is a/an #@occupation, but why does this method succeed where the previous one fails?"
end
end
end
end
If that is the code directly pasted in, you aren’t closing your initialize or sheet method definitions.
Who knows what could happen at that point.