When nothing isn't

I would dispute the notion that NULL or \0 are uninteresting in C. But that's not the question.

The Ruby language defines the value of an unset hash member as nil. Therefore,

my_hash[:bogus_key] == nil => true

Further, Ruby defines the behavior of nil in a conditional as evaluating to false, e.g.:

if nil   puts 'it is nil' else   puts 'it has a value' end

The session key deal is typically done as:

login_id = session[:user] || 0

Where the || conditional assignment provides some sensible default.

HTH

Wes Gamble-2 wrote: