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 trialPatrick Shushereba
10,911 PointsRuby address book question
I just had a quick question. In the exercise Build an Address Book, one of the lines is:
if !@middle_name.nil?
I completely missed the part about adding the exclamation point to the beginning. Can someone explain that to me?
1 Answer
Taylor Boudreau
7,285 PointsHi Patrick! I just did this myself. The !
means "not", so in this case you would read this as if the middle_name
is not nil
and contains some value return true
and run the code, however if the middle_name
is nil
this would return false and the code would not be run.
Patrick Shushereba
10,911 PointsPatrick Shushereba
10,911 PointsOh that makes so much sense. Thanks a lot.