Hi, you can try parse lines with regexp as follows:
hash = {}
File.open("RubyTokens.txt") do |f|
f.each_line do |line|
line =~ /"([^"]+)"=>(\d+),/
hash[$1] = $2.to_i
end
end
On 27 srp, 07:49, James Rasmussen <jamesras... / gmail.com> wrote:
> Update:
>
> For example, I'm trying something like this:
>
> hash_table = file_contents.each { |line| Hash[line.to_s] }
>
> And it's obviously giving me an error. With my limited programming
> skills, and my terminally-ill Ruby skillset, this is proving rather
> difficult. Thanks in advance for any help.
>
> --
> Posted viahttp://www.ruby-forum.com/.