Ruby Build an Address Book in Ruby Class Design Contact Class: Part 1

Patrick Shushereba
Patrick Shushereba
10,911 Points

Ruby 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
Taylor Boudreau
7,285 Points

Hi 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
Patrick Shushereba
10,911 Points

Oh that makes so much sense. Thanks a lot.