I am passing an argument as shown below
def hi value
value=(here I need to convert back to Hash from string)
puts value['key']
end
hi "h['key']" #I am passing hash as string
I am passing Hash as string and I need to convert back to hash as I have
shown above,Is it possible? The reason I am asking this is because the
error handling part has to be performed within function.
Raja gopalan wrote in post #1166205:
hi "h['key']" #I am passing hash as string
Where are the keys? Where are the values?
I am passing Hash as string and I need to convert back to hash as I have
shown above,Is it possible? The reason I am asking this is because the
error handling part has to be performed within function.
I have no idea what that is supposed to mean.
hi,
I got the answer just few hours back, the answer is eval function.
I will explain my condition below,
Actually, I am calling my function like this,
File 1
class String
begin
def set value
b.text_field.set value
end
rescue =>e
puts e.message
end
end
File 2:
begin
‘something’.set a[‘hi’]
rescue =>e
puts e.message
end
Now if some error happens at a[‘hi’] then it catches the exception part
of the File 2 and it stops the execution, but if catches the exception
in File 1 then it doesn’t stops the execution, that’s why I plan to send
to string format instead of hash like
‘something’.set ‘a[hi]’ and later in File 1 I plan to convert this back
to hash.
If you suggest me the better way, I would be happy for that.