You need to change your code to the following:
hash_weekdays = Hash.new
weekdays.each do |item|
hash_weekdays[item[0]] = item[1]
end
hash_weekdays
#=> {"Monday"=>2, "Tuesday"=>4, "Thursday"=>5}
When the first element of weekdays (["Monday",2]) is passed to the block, the block variable is assigned its value:
item = ["Monday",2]
Since you need to reference each element of item, it's common to use two block variables whose values are assigned using parallel assignment (aka multiple assignment):
day, nbr = ["Monday",2]
#=> ["Monday", 2]
day #=> "Monday"
nbr #=> 2
This allows you to write
hash_weekdays = {} # the more common way of writing hash_weekdays = Hash.new
weekdays.each { |day, nbr| hash_weekdays[day] = nbr } # used {...} rather than do..end
hash_weekdays
which is arguably clearer.
Notice that you first initialize hash_weekdays to an empty hash, then need the line hash_weekdays at the end if you wish to obtain the new value of the hash (as the last line of a method, for example). You can reduce this to a single line (very Ruby-like) by using the method Enumerable#each_with_object:
weekdays.each_with_object({}) { |item, hash_weekdays| hash_weekdays[item[0]] = item[1] }
#=> {"Monday"=>2, "Tuesday"=>4, "Thursday"=>5}
Notice this uses parallel assignment. The first element passed to the block, [["Monday", 2], {}], is assigned as follows:
item, hash_weekdays = weekdays.each_with_object({}).next
#=> [["Monday", 2], {}]
item
#=> ["Monday", 2]
hash_weekdays
#=> {}
The Ruby way is to use parallel assignment in a slightly more complex way:
weekdays.each_with_object({}) { |(day, nbr), hash_weekdays|
hash_weekdays[day] = nbr }
#=> {"Monday"=>2, "Tuesday"=>4, "Thursday"=>5}
As others have noted, the most straightforward answer is to use the method Hash::[] or (introduced in v2.0) Array#to_h:
Hash[weekdays]
#=> {"Monday"=>2, "Tuesday"=>4, "Thursday"=>5}
Hash[*weekdays.flatten] #=> Hash["Monday", 2, "Tuesday", 4, "Thursday", 5]
#=> {"Monday"=>2, "Tuesday"=>4, "Thursday"=>5}
weekdays.to_h
#=> {"Monday"=>2, "Tuesday"=>4, "Thursday"=>5}