I have a question about using local variables as values for ruby hashes.
I have to do a script that will gather meta data of video files in a
fixed directory and store them in an array of hashes. The problem is
that when I have collected the meta data to a hash called video and
append this to the end of videos array all the hash entries are the same
in the array. I assign the values to the hash and append to the videos
array with this script block:

video["res_w"] = res_w
video["res_h"] = res_h
video["dur_h"] = dur_h
video["dur_m"] = dur_m
video["dur_s"] = dur_s
video["dur_ms"] = dur_ms
videos << video

All the local variables have been initialized as zeroes and when my loop
retrieves another file for processing it reuses the local variables. The
actual question is does the hash store a pointer to the local variable
as its value? If it does is there a way to overwrite this behaviour or
some way around it?
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to