> Is
> if session[:foo]
> ...
>
> not good enough for you (or do you sometimes explicitly store nil in
> the session (and want that to be distinct from the value not being
> there at all) ?) ?
Actually the distinction between nil and nothing is exactly the issue;
but, it's not what you're thinking. It has to do with the definition
of truth.
My understanding is that in Ruby what is not true is limited to either
nil or the constant, false. My recollection is that, in the past on
some occasions, I have gotten myself into trouble by treating the
absence of a value as being equivalent to false. So, I keep reminding
myself that, in Ruby, the absence of a value is not equivalent to
false and I try to write code accordingly.
Now, I want to clarify the above statement. My recollection of the
cases in which I have previously gotten into trouble didn't involve a
hash; but, rather, I was doing something like, "if foo" and the
trouble arose when the foo variable had not been defined. So, I
realize that is not the same thing as a key being absent from a hash.
Perhaps I can get away with it in the case of a hash. If so, I'm just
going to have to expand my understanding of what constitutes false in
Ruby to include the absence of a key from a hash. So, out of
curiosity, is it your understanding that, in Ruby, false includes the
absence of a key from a hash?
Thanks.
... doug
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---