From: Gary Wright Date: 2011-03-04T02:46:05+09:00 Subject: Re: How to assign an element to a hash only if its value is not nil? On Mar 3, 2011, at 12:38 PM, Michael Edgar wrote: > If you don't mind also overwriting the value if the value is false as well as if the value is nil, > you can use the common ||= approach: > > hash[:key] ||= myvalue That is different than what the OP described as it depends on the existing value of hash[:key] but the OP wanted the assignment conditional on the new value ('myvalue'). Gary Wright