If the user is nil, then logged_in? will return a "falsey" value. Otherwise, it will return an object. In Ruby we don't need to return true or false, since we have "truthy" and "falsey" values like in JavaScript.
Update
If you're using Rails, you can make this read more nicely by using the present? method:
I arrived at this question looking for an object method, so that I could use the Symbol#to_proc shorthand instead of a block; I find arr.find(&:not_nil?) somewhat more readable than arr.find { |e| !e.nil? }.
The method I found is Object#itself. In my usage, I wanted to find the value in a hash for the key name, where in some cases that key was accidentally capitalized as Name. That one-liner is as follows:
# Extract values for several possible keys
# and find the first non-nil one
["Name", "name"].map { |k| my_hash[k] }.find(&:itself)
As noted in other answers, this will fail spectacularly in cases where you are testing a boolean.