Question: I am try to create a regular expression for a javascript project that covers every hyperlink that starts with "file://"

Thanks :)

Answer: 
You always need to initialize variables in Ruby.
But you can initialize hashes as following:

```
# Using {} to creates an empty hash
months = {}

# or create a new empty hash object from Hash class
months = Hash.new

# instead of
months = {"Feb"=>["day1", "day2"]}

```

To initialize a Array within a Hash:

```
# Array.new creates a new Array with size 5
# And values within Hash.new block are the default values for the hash
# i.e. When you call the Hash#[], it creates a new array of size 5
months = Hash.new { |hash, key| hash[key] = Array.new(5) }
puts months        #=> {}
puts months["Feb"] # Here the Hash creates a new Array inside "Feb" key
puts months        #=> {"Feb" => [nil, nil, nil, nil, nil]}
puts months["Feb"][3] = "Day3"
puts months        #=> {"Feb" => [nil, nil, nil, "Day3", nil]}

```

To do the same using an undefined array size:

```
months = Hash.new { |hash, key| hash[key] = [] }
puts months        #=> {}
months["Feb"].push "Day0"
puts months        #=> {"Feb" => ["Day0"]}
months["Feb"].push "Day1"
puts months        #=> {"Feb" => ["Day0", "Day1"]}

```

I think a more elegant approach is to use the map method to build your array of days before bind it to "Feb" key:

```
months = {"Feb" => (0..4).map{ |i| "day#{i}" }}
# => {"Feb"=>["day0", "day1", "day2", "day3", "day4"]}

```

If you don't want to type the month name you can require the Date class and get the month name passing an Fixnum:

```
require 'date'
months = {Date::ABBR_MONTHNAMES[2] => (0..4).map{ |i| "day#{i}"}}
# => {"Feb"=>["day0", "day1", "day2", "day3", "day4"]}

```

To generate the same structure for all months you can do:

```
days   = (0..4).map{ |d| "day#{d}"}
months = (1..12).map{ |m| {Date::ABBR_MONTHNAMES[m] => days }}
# => {"Jan"=>["day0", "day1", "day2", "day3", "day4"],
#     "Feb"=>["day0", "day1", "day2", "day3", "day4"],
#     ...
#     "Dec"=>["day0", "day1", "day2", "day3", "day4"]}

```

Some useful documentation:

* [Hash#new](http://www.ruby-doc.org/core-1.9.3/Hash.html#method-c-new)
* [Array](http://www.ruby-doc.org/core-1.9.3/Array.html)
* [Enumerable#map](http://www.ruby-doc.org/core-1.9.3/Enumerable.html#method-i-map)
* [Range](http://www.ruby-doc.org/core-1.9.3/Range.html)
* [Date](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/date/rdoc/Date.html)
Based on what you guys said I messed around and it looks like Ruby wants the key to exist before you can start assigning values to that key.

```
hashname = Hash.new
hashname[:foo] = {}
hashname[:foo][3] = "test"
hashname[:foo][1] = "test1"
hashname[:bar] = {}
hashname[:bar][3] = "test3"
puts hashname
puts hashname[:foo][1]

C:\Ruby>scratch.rb
{:foo=>{3=>"test", 1=>"test1"}, :bar=>{3=>"test3"}}
test1

```

Once the key exists, you can start assigning values as you please. Although in this case you can see that I am creating a "hash of hashes" instead of a "hash of arrays" as the .map method does which still eludes me as to why.

Thanks for the help!