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 trialfederico enrico
6,143 PointsI get an error trying to run the last part of this Variables video
class Fede
def initialize(title, first_name, middle_name, last_name)
@title = title
@first_name = first_name
@middle_name = middle_name
@last_name = last_name
end
def title
@title
end
def first_name
@first_name
end
def middle_name
@middle_name
end
def last_name
@last_name
end
end
name = Fede.new("Mr")
puts name.title + " " +
name.first_name + " " +
name.middle_name + " " +
name.last_name
And this is the Error message I get
name.rb:2:in `initialize': wrong number of arguments (1 for 4)
(ArgumentError)
from name.rb:25:in `new'
from name.rb:25:in `<main>'
Please, help
1 Answer
Maciej Czuchnowski
36,441 PointsI answered this here:
https://teamtreehouse.com/forum/for-me-this-code-doesnt-pass-unless-you-pass-in-the-new-4-parameters
There was a cutscene where I'm pretty sure more stuff got changed than we see in the video.
The line near the bottom should say:
name = Fede.new("Mr", "Jason", "", "Seifer")
federico enrico
6,143 Pointsthanks, sorry, I thought about it for a while than managed to solve it by myself, I just went through the video a couple of times but couldnt find it :(
Maciej Czuchnowski
36,441 PointsYeah, Jason doesn't show this part and it just has to be there :). Otherwise the code will never work.
federico enrico
6,143 Pointsfederico enrico
6,143 PointsI kinda solved this by thinking about it and doing this, but is this mentioned in the video?
name = Fede.new("Mr", "Barack", "Hussain", "Obama")