From: yermej Date: 2007-12-02T13:09:59+09:00 Subject: Re: Scrabble Stems Ruby Quiz question. On Dec 1, 8:48 pm, Mark Woodward wrote: > Hi all, > > could someone explain the line: > (STEMS[stem] ||= {})[letter] = 1 > in the code below? It's equivalent to: STEMS[stem] = STEMS[stem] || {} STEMS[stem][letter] = 1 Where that first line means: if STEMS[stem] isn't defined, assign a new Hash to it. It could also be done like this: STEMS = Hash.new {|h, k| h[k] = {}} # near the top of your example code STEMS[stem][letter] = 1 # and this in place of the line you asked about Hash.new allows you to use a block to define the behavior of the hash if the element isn't found. With no block (as in the example code you posted), nil is returned.