threadify not handling hashes inside of array correctly

J

Jarmo Pertman

I wanted to use threadify to iterate over my data structure, where
inside array I have hashes, but it seems that threadify produces
different results than #each.

Here is code sample:
require 'threadify'

a = []
b = {:key => "value"}
a << b

a.each {|c| p c}
a.threadify {|c| p c}

Output is:
{:key=>"value"}
[:key, "value"]


Now, if I have multiple key, value pairs in Hash, then I will get this
warning of course:
warning: multiple values for a block parameter (2 for 1)

Why isn't threadify working as expected? It seems as it's iterating over
array and hash instead of just over array.

Jarmo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top