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 trialRoberta Voulon
5,792 PointsNSNumber *planck;
Hello! I can't seem to see what's wrong with this... The error says to make sure to assign the correct value, which is 6.626...
// NSNumber *planck = [NSNumber numberWithFloat:6.626];
5 Answers
Joseph Potts
11,187 PointsNot sure why it isn't working, but this will work.
NSNumber *planck = @6.626;
It's shorter, cleaner, and elegant. It basically does all the initialization work for you, you just have to include the '@' symbol.
Roberta Voulon
5,792 Pointswell yeah I know that... but that's exactly how I did the foxtrot question right before, I assumed I had to do something different this time... bit silly I think to ask twice for the same answer, and then say it's wrong when I use the alternative class method exactly like in the video.
Roberta Voulon
5,792 PointsI think I will log it as a bug, thanks a lot Joseph for the quick reply!
Joseph Potts
11,187 PointsNo problem! Yeah I tried to initialize foxtrot using a message call too, it worked there. Probably a bug in the challenge. In a way it's good, it encourages smaller and more readable code.
Michael Hulet
47,913 PointsIf you're trying to run that exact code, it won't work, because of the //
at the beginning of the line. That character marks that everything after it on the line is a comment, so the compiler ignores anything to that character's right, so the code you posted will never run. For future reference, though, I find the shorthand syntax easier:
NSNumber *planck = @6.626;
Roberta Voulon
5,792 PointsI just added the // quickly in my post because the forum deleted the code, so I pasted the code back in and commented it out so it would pass. too lazy to check out what the proper tags are so it will parse :) I still think my original answer should have been accepted because in the video this was demonstrated as an alternative way, and I thought that's what they wanted me to do since the previous answer was already using the literal assignment (@syntax)
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsThat line won't compile, because you forgot the semicolon
Joseph Potts
11,187 PointsJoseph Potts
11,187 PointsWhoops! Edited, thanks ;)