From: Jake McArthur Date: 2006-07-27T17:16:57+09:00 Subject: Re: ||= in an expression --Apple-Mail-1--412649043 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Jul 27, 2006, at 3:10 AM, rejoc wrote: > Hello, > > I new to Ruby and curious about this language I do use (yeet). > > I was browsing through some libraries/modules and I found a line > looking like > > a[:i] ||= "a string" > > I could not find this syntax in any manual online (and googling "|| > =" is not of much help :-( ) > > Can anyone tell me what it means > > TiA > Consider: "some string" || "a string" versus: nil || "a string" The former returns "some string", but the latter returns "a string". Apply that to the form you described and it basically means that if a [:i] is nil then it assigns "a string", otherwise it leaves it alone. - Jake McArthur --Apple-Mail-1--412649043--