During class on Thursday, Brit was finishing up walking us through creating a blogging site. He put up the following code on the screen to check whether the user was logged into the blog:
As I was wondering to myself why he didn’t put a ! on the end of the method name, Brit explained the method returns the ActiveRecord user object if the user is in session and exists in the database.
From my many years writing in C, I fully expected the function to return a boolean value of true or false! So many questions flew through my mind so I quickly started pry and began typing.
Ruby evaluates the item on the left side, and if not false or nil it evaluates and returns the results of the item on the right side of the &&…..
Ruby is an amazing language! I am working hard absorb it all so I can utilize its features in thoughtful ways when I write code. Class is starting to move faster, but I don’t even care. This is awesome!!