Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlphonse Cuccurullo
2,513 Pointsundefined method?
class Message @@messages_sent = 0 def initialize(from, to) @from = from @to = to @@messages_sent += 1
end
def description
case @from
when "Alphonse","alphonse" then puts "Thank you for caring clauds"
else
puts "idk"
end
end end
class Email < Message def initialize(subject) @subject = subject end end
my_message = Message.new("Alphonse","clauds") my_message.desciption
Its saying that the description method is undefined. I tested this out in on my note pad and code academy an it says the same thing.
1 Answer
Clayton Perszyk
Treehouse Moderator 48,850 PointsAlphonse,
You're getting that error because your call to description is missing an 'r'; however even after that you will encounter errors. Below is working code.
class Message @@messages_sent = 0
def initialize(from, to)
@from = from
@to = to
@@messages_sent += 1
end
def description
case @from.downcase
when "Alphonse"
puts "Thank you for caring clauds"
else
puts "idk"
end
end
end
class Email < Message
def initialize(subject)
@subject = subject
end
end
my_message = Message.new("Alphonse","clauds")
puts my_message.description
Best,
Clayton