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 trialJeeya M
16,839 Pointsnot a statement
name == "Friend"; is underlined red and says not a statement
if (name == null){
name == "Friend";
}
1 Answer
Robert Richey
Courses Plus Student 16,352 PointsHi Tegh,
The double equals operator (==
) is checking for equality, like Francisco mentions. In the video, however, the code is using a single equals (=
) which is the assignment operator.
It basically reads like this: if name is null, then assign to name the value of "Friend"
Cheers
Jeeya M
16,839 PointsThanks a lot Robert Richey
frvncisco
3,101 Pointsfrvncisco
3,101 PointsThe == operator cannot be use in that way. are you trying to compare strings? if yes, you should use the .comparesTo() method. Read this