Actually, the hash = Hash.new(false); written in the question is completely unnecessary. The meaning of this sentence is actually
Actually I just want
Hash.new { Hash.new(false);}
is enough.
Second question: If item_array does not have a member with symbol sindex, then execute the previous @item_array[i] = []. This syntax is to post clauses such as if (or while unless). What it expresses is actually
First question: http://ruby-doc.org/core-2.1.0/Hash.html#method-c-new
Let’s write a few more sentences. There are two ways to use it
or
Actually, the hash = Hash.new(false); written in the question is completely unnecessary. The meaning of this sentence is actually
Actually I just want
is enough.
Second question: If item_array does not have a member with symbol sindex, then execute the previous
@item_array[i] = []
. This syntax is to post clauses such as if (or while unless). What it expresses is actually=>
Essentially, there are a few lines missing. .